![]() |
| | #1 |
| Cogito Ergo Sum Join Date: Mar 2007 Location: Sydney, Australia
Posts: 459
| Error with first socket program undefined reference to WSAStartup undefined reference to WSACleanup Code: //#include "stdafx.h"
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WSADATA ws;
char buf[1000], buf1[100], buf2[100], buf3[100], buf4[100], buf5[100], buf6[100];
WSAStartup (0x0101, &ws);
buf[0] = "";
sprintf(buf1,"\nWinsock Ver Requested : %d.%d", HIBYTE(ws.wVersion), LOBYTE(ws.wVersion));
sprintf(buf2,"\nWinsock Ver Available : %d.%d", HIBYTE(ws.wHighVersion), LOBYTE(ws.wHighVersion));
sprintf(buf3,"\nCurrent WinSock Implementation: %s", &ws.szDescription);
sprintf(buf4,"\nSystem Status : %s", &ws.szSystemStatus);
sprintf(buf5,"\nMaximum Sockets : %u", ws.iMaxSockets);
sprintf(buf6,"\nMaximum Message Size : %u", ws.iMaxUdpDg);
strcat(strcat(strcat(strcat(strcat(strcat(buf,buf1),buf2),buf3),buf4),buf5),buf6);
MessageBox(0,buf,"Info",0);
WSACleanup();
return 0;
}
|
| JFonseka is offline | |
| | #2 |
| Cogito Ergo Sum Join Date: Mar 2007 Location: Sydney, Australia
Posts: 459
| Aha, I found the answer, I'm supposed to link as such: gcc -Wall -o socket socket.c -lws2_32 |
| JFonseka is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with simple socket client/server program | spencer88 | C Programming | 6 | 05-05-2009 11:05 PM |
| Need help with my program... | Noah | C Programming | 2 | 03-11-2006 07:49 PM |
| Writing to an Output Socket in use by another program | maththeorylvr | Windows Programming | 4 | 10-28-2005 12:17 PM |
| my server program auto shut down | hanhao | Networking/Device Communication | 1 | 03-13-2004 10:49 PM |
| My program, anyhelp | @licomb | C Programming | 14 | 08-14-2001 10:04 PM |