How the **** do I get Visual C .net to open a TCP socket connection

By keechow ·
What is a "Bullet-proof" method of setting up a SOCKET using Visual I've been trying to run it with my code but I KEEP getting an ERROR when it RUNs. The code is as follows:

String^ remoteName = "localhost";

Socket^ clientSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp );
System::Net::IPAddress^ ipAddress = System::Net:ns::GetHostEntry("localhost")->AddressList[0];
IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress, 1800 );
clientSocket->Connect( ipEndPoint );

I'm using Visual on Visual 2005 Frameworks (3.0).

*** Note: ***
I can NOT use the "Dns::Resolve" command since its been obsoleted...

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Using the windows include?

by IC-IT In reply to How the **** do I get Vis ...

I haven't played with .Net yet, but did find these clues;

has implented their own version very similar to the BSD sockets API.
The include file for this is simply <winsock2.h>. You will also have
to link the WS2_32.lib to your program. This can be done in the
project settings menu. Another issue of importance is the way that
the API is implemented. Even though it is very similar to coding
sockets on other systems, it still has its differences. For example
you must call WSAStartup() before you even call socket(). Once you
see the code however you should be more than comfortable with coding
sockets in windows.

And a potentially nice reference site; (It initially looks like a C tutorial, but has a special .Net section dedicated to the winsock).

Related Discussions

Related Forums