How do I use sockets in Windows? I have tried so hard to find the socket headers required for linux-like sockets (Berkley/POSIX/whatever), but I just can't find them. I AM NOT GOING TO USE VISUAL C OR SIMILAR!
If it doesn't work with TCC or at least GCC, then F**K it! amateur crap!
I am getting quite pissed, for such a simple task to be so difficult T_T
socket programming
Started by kenna, Jul 28 2007 09:22 AM
2 replies to this topic
#1
Posted 28 July 2007 - 09:22 AM
|
|
|
#2
Posted 12 July 2010 - 02:21 PM
I recommend you look up Beej's networking tutorials. I don't think you would need the tutorial parts but the examples will show you the headers needed. I'll give you a quick example though:
#ifdef WIN32
#include <ws2tcpip.h>
#include <windows.h>
#include <winsock2.h>
#include <w32api.h>
#define sock_cleanup() WSACleanup();
#endif
int sock_init ( void )
{
#ifdef WIN32
WORD wVersionRequested;
WSADATA wsadata;
wVersionRequested = MAKEWORD(1,1);
WSAStartup(wVersionRequested,&wsadata);
#endif
return 1;
}
int main ( int argc, char ** argv )
{
init_socks();
//Your socket-related code here.
sock_cleanup();
}
#3
Posted 12 July 2010 - 05:57 PM
Sea, I've noticed you've been answering threads that are really old. Please try not to answer anything whose last post is more than a month or so old, as the people involved are probably no longer paying attention. It also pushes down newer threads, with people still involved, in the recent list. Welcome to CodeCall, by the way. :)
sudo rm -rf /


Sign In
Create Account


Back to top









