im python to make a simple script to connect to another socket server but im having an issue in getting my servers ip using socket before i used
socket.getbyhostname(socket.gethostname()) but im getting the error `AttributeError: ‘socket’ object has no attribute ‘gethostname’
ive tried importing everything from socket by using
from socket import * but now im getting the error
type object 'socket' has no attribute 'socket'
can someone explain whats going on and why this is a problem for me in the firstplace as ive used the same line before with no issues
import socket socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) HOSTNAME = socket.getbyhostname(socket.gethostname()) print(HOSTNAME) #constantly wait for a connection print("Waiting for a connection...") while True: #listen for a connection socket.bind(("", 9998)) socket.listen(1) conn, addr = socket.accept() print("Connected to: ", addr)