Hi guys.
Nice forums  :)

I'm going to tackle sockets for the first time.

What i want to do is this.

Send a custom udp packet either in console or gui.

The packet is being used for a program i'm making for online game.

my packet

1 IP_Version b: 4 0 4
1 IP_HdrLen b: 4 0 5
1 IP_Tos b: 8 0 0
1 IP_TotLen b: 16 0 33
1 IP_Id b: 16 1 0
1 IP_FragOff b: 16 0 0
1 IP_TTL b: 8 0 128
1 IP_Proto b: 8 0 17
1 IP_Hcksum b: 16 3
1 IP_Src b: 32 4
1 IP_Dst b: 32 4
2 udp_sport b: 16 0 1250
2 udp_dport b: 16 0 27015
2 udp_length b: 16 0 13
2 udp_csum b: 16 0 0
2 DATA B: 5 2 ????T

Could you please tell me what type of sockets ,blocking non blocking etc.

Thanks so much.

Posted on 2005-07-20 08:45:23 by gavin
Heya :)

I'm willing to help you out with network programming.
Think Big - Start Small is my motto.
I recommend you begin with a "simple blocking client" and a "simple blocking server".
Don't get caught up on non-blocking (asynchronous) socket code just yet.
First, get a basic grip on Socket coding.
Next, it's time to add an application window (if you didn't already), and try out your first asynch socket model, which uses "WSAAsyncSelect", that causes "Socket Messages" to hammer on your application's "Windows Message Pump", so you get notified of "socket events" via the same mechanism as you handle "WM's".
Next, it's time to push that model hard, so you can see why it's a bad choice (too many WMs are generated, which chokes your application so that the GUI freezes up, etc)
Next, we investigate another Asynch socket model, we replace the WSAAsynchSelect call with a call to WSAEventSelect. Like the first socket model we tried, we don't need any App Window, since we're not using the WM notification system anymore. This time we have to create an "event object" which Windows will trigger for us when "SocketEvents" occur.
We'll need to decide how best to "poll" the event object, and there's several options for that.
We've basically covered all of the socket models now, the only thing left for us to investigate is Threading models, and the last thing to check out among those is "IO Completion Ports".
This Threading model is capable of handling THOUSANDS of sockets at once, and can be used for a not of non socket related purposes as well.

As you can see, there's plenty to learn about, but not TOO much.
If you spend a few weeks playing with each model, we're talking about three or four months between now and GodLike Status.

Well? What are you waiting for? :)
Posted on 2005-07-21 01:52:12 by Homer
Hi EvilHommer.

Thanks for the reply .

I'll read on the blocking sockets thanks.

I'll reply later.
cya :)
Posted on 2005-07-21 05:29:19 by gavin
You should have a look at www.madwizard.org , he has some pretty okay tutorials for winsock programming.
Posted on 2005-07-21 10:49:00 by f0dder

Have a look at FASt Server http://www.jamesladdcode.com.
It doesnt do UDP yet, but it is an example of Overlapped Socket IO.
Im hoping to do a UDP server extension soon.

Im happy to answer questions etc.

Rgs, James.
Posted on 2005-07-21 18:47:12 by James_Ladd