Take the 2-minute tour ×

Ive searched internet but didnt got the answer can any1 explain me the difference between them

share|improve this question

2 Answers 2

up vote 0 down vote accepted

A TCP "connection" is a 4-tuple. Local IP, Local Port, Remote IP, and Remote Port. Each end maintains this identification within its TCP stack, with the senses reversed (Local vs. Remote).

The combination of these 4 values must be unique. This explains the problems people often have writing a TCP client that reuses a socket to reconnect to the same server.

A "closed" connection leaves this ID in the tables at each end for some time, in TIME_WAIT state. This is an artifact of a TCP mechansim that deals with maintaining connection integrity even if the physical layer connection breaks, keeps pending packets from being recevied by a second connection, etc. TIME_WAIT can last up to 4 minutes.

Unless the client resets its socket's LocalPort to 0 (which is a request for an automatic ephemeral port assignment) it can fail if it tries to reconnect before TIME_WAIT expires. Since this is 0 for a newly created socket, programmers often overlook this requirement prior to calling Connect.

LocalPort isn't just an issue for listening sockets.

share|improve this answer

A server listens on a localport, while a client sends data from the localport. The client remoteport should be the same as the server localport. i.e.: Server listens on port n (local port relative to server) Client connects to server on port n (remote port relative to client)

To answer your question, the difference is in name, based on perspective.

This seems to be a good place to start with VB6 socket communication

share|improve this answer
Can i ask you 1 more thing- ive done everything correctly in connecting client and server on WAN but my ip is dynamic that means it change everytime, so i make a named ip that is no-ip but is it possible to connect my winsock like this winsock.connect "mynamedip.no-ip.com" 50505 'my port is 50505 –  Sam Jan 17 '13 at 23:00
That works unless your server is behind a NAT router. Then your router needs to have a port forwarding rule to make it work. Private networks like the common network provided by small NAT routers are not inbound-routable using normal rules, and need help from extra mapping rules. –  Bob77 Jan 18 '13 at 3:18
ive already port forwarded at 50505. The problem is i made a reverse connection in which server acts as a client and client acts as a server. Just to assure myself i need to ask u a question. Ive learnt that port should b opened on server computer on which server is listening but it does not required on Client computer, Winsock does that by itself. Is it true. ?? –  Sam Jan 18 '13 at 18:22

Your Answer


