# Strange socket error

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

## Recommended Posts

Hey, As you may notice I'm a newbie with Allegro. I'm making a client for my game(server done in a pair of days), but I have some problems with sockets, as this line doesn't really...work: if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) I have included winalleg.h and linked libwsock32.a, if that really makes sence for you anyway. The thing that happens when that line is called the whole sh*t crashes >.> Anyone got an idea? Maybe I should post the full code, if yes, tell me.

##### Share on other sites

- Does it crash if you don't call any winsock functions?
- If so, does it crash if you don't link winsock
- If so, then the problem is definitely unrelated.

What does your debugger tell you about how it crashed? Has wsadata been corrupted to an invalid pointer somehow?

Have you somehow destroyed some of the C runtime's data by a previous pointer error? If so, a crash can subsequently happen anywhere, including inside functions which should not crash.

- How can you possibly have a game server if the client isn't made?
- For me, the two things have to be developed in tandem - they can't be individually tested.

Mark

##### Share on other sites
Uhm don't know much about Allegro, does it provide its own Winsock headers and libs? Are you sure you're requesting the latest Winsock version?

Winsock2.h
ws2_32.lib

##### Share on other sites
No idea where WSADATA is defined, but I use this same code for my 'DOS Prompt' test client(What I test the server with)

The debugger tells me that I crashes on that line, the backtrace just says

libwsock_a_iname
??

And no it does not crash if I don't call my "startUp" function(The function only checks if there is no errors with that part and then keeps going into the next step)

Edit: Well socket.h

##### Share on other sites
Hi,

Are you using MSVC?

Try:

#include <allegro.h>#include <winalleg.h>//#include <winsock2.h>

I haven't used allegro in a long time, but I recall having the same problem as you have. Possibly you could ask at the allegro forums if my solution doesn't work. I'm sure that many a person has come across the same problem.

Later,

GCS584

##### Share on other sites
Quote:
 Original post by gcs584Hi,Are you using MSVC? Try:*** Source Snippet Removed ***I haven't used allegro in a long time, but I recall having the same problem as you have. Possibly you could ask at the allegro forums if my solution doesn't work. I'm sure that many a person has come across the same problem.Later,GCS584

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 12
• 12
• 20
• 12
• 13
• ### Forum Statistics

• Total Topics
632152
• Total Posts
3004466

×