Sign in to follow this  

WinSock+SDL Error!!

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

okay this is really starting to annoy me, would anyone here beable to explain why this is happenning? can winsock not work with SDL? is that it? this is the original code and it works fine When i add, this it gives me a fatal error. why is that? when i have just this code alone it works fine, and when i have the other alone it has problems #include <SDL.h> SDL_Surface *screen; void main(int argc,char argv[]) { screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF); ... } ----------------ORIGINAL------------------------- /**************************************************** Networking Tutorials #2 Making the Connection - ClientSide by redKlyde ****************************************************/ #include <winsock2.h> #include <stdio.h> #include <SDL.h> #include <conio.h> void main() { printf("Client\n"); printf("Making the Connection - ClientSide\n\n"); int error; WSAData wsaData; error = WSAStartup(MAKEWORD(2, 2), &wsaData); if (error == SOCKET_ERROR) { printf("Could Not Start Up Winsock!\n"); return; } printf("WinSocket started\n"); int mySocket = socket(AF_INET, SOCK_STREAM, 0); if (mySocket == SOCKET_ERROR) { printf("Error Opening Socket!\n"); } printf("Socket Opened!\n"); char server_name[40] = "localhost"; struct hostent *host_entry; host_entry = gethostbyname(server_name); if (host_entry == NULL) { printf("Could not find host!\n"); } struct sockaddr_in server; server.sin_family = AF_INET; server.sin_port = htons((unsigned short) 7654); server.sin_addr.s_addr = *(unsigned long*) host_entry->h_addr; error = connect(mySocket, (sockaddr*)&server, sizeof(server)); if (error == SOCKET_ERROR) { printf("Error connecting to server!\n"); } closesocket(mySocket); printf("Socket Closed\n"); WSACleanup(); printf("WinSocket Shutdown\n"); printf("Press any key to continue ...\n"); getchar(); getch(); }

Share this post


Link to post
Share on other sites

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this