TCP Server Issues

When Attempting To Write The TCP Server for the Information Security Course on freeCodeCamp when running it came up with this error
```
PS C:\Users\Gavyn\Documents\GitHub\python-pentesting> & C:/Python311/python.exe c:/Users/Gavyn/Documents/GitHub/python-pentesting/tcp-server/server.py
Traceback (most recent call last):
File “c:\Users\Gavyn\Documents\GitHub\python-pentesting\tcp-server\server.py”, line 8, in
host = socket.gethostbyname()
^^^^^^^^^^^^^^^^^^^^^^
TypeError: gethostbyname() takes exactly 1 argument (0 given)
PS C:\Users\Gavyn\Documents\GitHub\python-pentesting>


[Here is a link to my code on Github](https://github.com/gryffindro/python-pentesting/blob/main/tcp-server/server.py)

Hi @galejandro , the error itself is telling you what is going on. You are trying to use a function that needs a parameter and is not optional. According documentation, you have to pass it the hostname “hostname - The name of the host system for which IP address resolution is needed.” for example:

hostName    = "example.org"

ipAddress   = socket.gethostbyname(hostName)

I hope it helps. bests

Hi @ssulbaran, thank you so much. That makes a bit more sense now.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.