Jump to content
  • Advertisement
Sign in to follow this  
Thanhda

WinSock+SDL Error!!

This topic is 5053 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
Advertisement
You must post what specific error you're getting for us to have any idea what the problem might be. You might want to read the FAQ on how to ask smart questions.

Share this post


Link to post
Share on other sites

This topic is 5053 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  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!