Can't get a simple TCP program to work

I

Irmen de Jong

Zach said:
The following *extremely* simple script complains that "Socket is not
connected" when I try to call recv. Could anyone provide some quick
guidance?

http://pastebin.com/m64317b32

replace node2.recv() by new_socket.recv() - you need to get data from the
client socket that you got from accept(), not from the server socket...

--irmen
 
D

Dennis Lee Bieber

The following *extremely* simple script complains that "Socket is not
connected" when I try to call recv. Could anyone provide some quick
guidance?
From the help files:

"""
accept( )

Accept a connection. The socket must be bound to an address and
listening for connections. The return value is a pair (conn, address)
where conn is a new socket object usable to send and receive data on the
connection, and address is the address bound to the socket on the other
end of the connection.
"""

Note the phrase: "a new socket object usable to send and receive
data".

So... don't do node2.recv(), use new_socket.recv()

If you really want to receive the data using node2, then don't use
listen()/accept()

--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top