I create a socket, 'bind' and 'listen' after that. No errors here. When I connect to this socket I receive messages - FD_CONNECT, FD_ACCEPT, FD_CLOSE (when closing). The problem is that I don't receive FD_READ and FD_WRITE when I try to send data :| The error code returned is WSAEINVAL, which means, the socket is not bound. But I bound it immediately before listen. I try to bind it again immediately before send, but the same error code is returned - WSAEINVAL, which means the socket is already bound. Can someone gimme a piece of advice ? Second question: Do I need to bind the socket before connect ? Thanx
Posted on 2001-05-10 00:26:00 by fla
fla, on the server side you must bind the socket, i.e. give the end-point a name. WSAEINVAL should mean the socket is already bound to an address? hth vesa
Posted on 2001-05-10 01:40:00 by vesa
vesa, thank u for replying ! Yes, I bind the socket, but I use INADDR_ANY. I think the server side uses this for listening to any address. I tried to bind the socket to determined address, but it always returns me an error. So I can only bind using INADDR_ANY... I really can't understand what's going on here :|... Thank u once again.
Posted on 2001-05-10 14:55:00 by fla
fla, the most server applications set their IP address to INADDR_ANY. This means the server accepts connections from any network its connected to. This is an issue when the server has more than one network card. I changed in my tcp based echo sample the sin_addr.in_addr in INADDR_ANY and it still works. I can mail you the server and client parts. vesa
Posted on 2001-05-15 03:26:00 by vesa
vesa, thank u for replyin' ! I wrote the sockets... I understand how they work. (As far as I can understand them now ;) I'm a newbee here :]]...) If any other questions arise I'm here again :) Thanx once again.
Posted on 2001-05-19 15:44:00 by fla
fla: Perhaps your understanding about bound socket is incomplete. The steps on the server side are like this: -create a socket -bind it to IP/port -listen for connection The steps on the client side: -create a socket -connect to the server ip/port Now when the connection is established: -on the server side, you receive FD_ACCEPT notification message on the listening socket. You must call accept() to accept the incoming connection. accept() creates a new socket for each connection so the listening socket is still listening for connection. The point is that: you cannot use the listening socket for other purposes like sending/receiving data once you call listen() on it.
Posted on 2001-05-19 19:23:00 by Iczelion