Advertisement

socket

Started by September 25, 2002 11:04 PM
32 comments, last by Tran Minh Quang 22 years, 4 months ago
If your server program opens up a socket and starts to listen on it (EG port 5000) then that port has been ''taken over''.
No other application can open it for use.

However, with this being said -- _any_ application can connect to that port. -- All the app has to do is open up a new port (such as 5001) and then use that socket to connect to the remote socket (in this case, 5000)

Your problem may be your client app is trying to utilize port 5000 for its port... which will already be in use by the server app.

May sound confusing, but if you read it over again and again till your eyes are as bloodshot as mine tend to get then it makes perfect sense
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
This is what i use in my error program.

#include <winsock2.h>

and lib: Ws2_32.lib

Are they the factor make my program error?
Advertisement
Yeah. My server program bind() port 5000 and currently running.
But server and client must agree the same port, right?
Oluseyi, I know winsock2 is the prefered socket library to use now. I''m just using winsock for learning purposes now. I do plan to move to Winsock2, though.

WinSockInit() is a wrapper function defined by me to startup winsock 1.1. It uses WSAStarup too

I don''t have a signature
I don't have a signature
>>Yeah. My server program bind() port 5000 and currently running.
>>But server and client must agree the same port, right?

If your server program binds() to port 5000... The client program cannot create a socket on that port number.
Create one on a port like 5001.

That should solve your problem.
"1 is equal to 2 for significantly large quantities of 1" - Anonymous

If your server program opens up a socket and starts to listen on it (EG port 5000) then that port has been ''taken over''.
No other application can open it for use.

So you mean the client program want to take over port 5000 of server?
Advertisement
May be i understand the problem. I will try it when i come home
I checked the error 10065.

WSAEHOSTUNREACH
(10065)
No route to host.
A socket operation was attempted to an unreachable host. See WSAENETUNREACH

WSAENETUNREACH
(10051)
Network is unreachable.
A socket operation was attempted to an unreachable network. This usually means the local software knows no route to reach the remote host.
I don't have a signature
Thanks for all of you. I will tell you when pass the bug
So i should replace 500 or lower than 5000?

This topic is closed to new replies.

Advertisement