Hello,

I have a server and client file.

In Client I have

WSADATA WsaData;
SOCKET Socket;

In server I have

WSADATA xxx;
SOCKET yyy;

This is same in both files:

sock_addr.sin_port = htons(1234);

Will this connection be established?

No. here is one of many tutorials found with google.

the server will bind to an address and start listening on it. the client socket is usually dynamically bound and tries to connect to the socket at the address the server has bound. so the port the client tries to connect to should be the same as the one the server used in the call to bind.
1234 is not an ideal choice for the port though. see http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

will this connection be established? can't say. the port may already be in use (for 1234, this is likely in windows), the connection may be blocked/dropped by a firewall etc.

OK, thanks

It works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.