-
Connecting With IP
Hello, I just recently joined the forum after browsing through the site for a week or so. Great forum!
Anyways, Im planning on making a chess program where you can connect to another player through their IP address. Any suggestions on how I could do this? Also if there are any links to where I can learn any techniques on how to do so would be great :D
-
research tcp/ip, sockets i think, not an expert, but thats where u start i think
-
-
Depending on the platform your working on, you have aceess to the BSD socket api. on linux it is as it, and microsoft has a version as well. Google for bsd sockets api if your on linux. though i'm pretty sure your not. ;)
-
DirectPlay (Part of the DirectX API) would be pretty handy if you want to wet your whistle a bit.
Otherwise, WinSock is a word that will most likely come up.
-
Shouldn't this be in the Network forum?
-
Thanks
Ok thanks guys, Ill search up some of these topics :)
-
Hmmm
I tried that Beej site, but its all Unix, Im developing this in Win32 :rolleyes: Any other suggestions? WinSock seems alot more complicated than how I use it back in VB...
-
Your gonna need to learn to start using google
-
-
I used this site:
www.gametutorials.com
>>but its all Unix
err...not too sure, but isnt it based off of Unix? I used that tutorial and the one above and they worked for me and I am on Windows too.
-
>>but its all Unix, Im developing this in Win32 :rolleyes:
WinSock is built to be as compatible with the Unix sockets as possible, so even if the underlying implementation is different, the usage should be the same in almost every way.
>>WinSock seems alot more complicated than how I use it back in VB...
So is just about everything. Suck it up and start learning ;) Really, once you've written a wrapper class for Winsock in C++, it's quite easy to use - even more so than the VB winsock control (I hated the blasted thing... ended up doing my project in C++ instead :p).
-
Here's something to get you started .... I know I had some tutorial on the net regarding this subject, but I don't seem to remember were I found them......
PHP Code:
void CClient003Dlg::OnBnClickedButton1()
{
WORD sockVersion;
WSADATA wsaData;
sockVersion = MAKEWORD(2, 0); // We'd like Winsock version 1.1
WSAStartup(sockVersion, &wsaData); // We begin by initializing Winsock
SOCKET My_Socket = socket(AF_INET, // Go over TCP/IP
SOCK_STREAM, // This is a stream-oriented socket
IPPROTO_TCP); // Use TCP rather than UDP
sockaddr_in My_Client; // Use a SOCKADDR_IN to fill Address info.
//%%%%%%%%%%%%%%//
// Client Part //
//%%%%%%%%%%%%%%//
My_Client.sin_family=AF_INET;
My_Client.sin_port=htons(2000);
My_Client.sin_addr.s_addr=inet_addr("127.0.0.1");
if(connect(My_Socket,(LPSOCKADDR) &My_Client,sizeof(My_Client))==SOCKET_ERROR)
{
WSACleanup();
closesocket(My_Socket);
return;
}
char *msg = "Ola Daniel"; // Message to be sent
int len, bytes_sent;
len = 80; // Maximum number of bytes to send :-)
bytes_sent = send(My_Socket, msg, len, 0);
}
-
Thanks for that link DeepFrye, that site really helps. :D:D:D:D