SDL_Net

Hi!

Recently, I’ve been trying to modify someone’s SDL code to handle
transmitting data via a UDP socket with the SDL_Net library.
Unfortunately, I’ve been having trouble setting it up and haven’t found
too much documentation on it.

Can anyone give me any pointers to web sites or source code that uses the
SDL_Net library, preferably with UDP sockets? I’ve looked at Sam’s code
for the chat application, but I need something a bit more dumbed down for
me.

I REALLY appreciate any help with this.

Thanks a lot,
Dave Jones

Hello!

How does it work this library (SDL_Net)?
I want to use SDL_Net Library using Win32 and only TCP Sockets for create a net game (no chat), i don’t understand very good the function of the commands (SDL_Net).

Thanks.

Does anyone one about a tutorial or atleast som
ducumentation for SDL_NET??

emh, the docs link on libsdl.org seems not to go! are there other infos
around?

Just read the SDL_Net document dated 22 December 2001. I was pretty
happy with it right up until the part on socket sets. It looks like
there should have been an iterator function to scan a socket set and
return ready sockets. Also, I didn’t see any way to tell what kind of
activity a socket was ready for. Usually a socket set has a set of flags
so you can tell if the socket is ready for reading, writing, or has hung
up.

Have these features or something like them been added in a later version
of the library? Are there plans to add them? Or, am I missing something
that makes it impossible to implement these features in a portable way?

	Bob Pendleton.

hi, im trying to write a game that uses SDL_Net and i was wondering if its possible that packets i send could get broken up so the server would recieve lets say a UINT16 in 2 packets, each made up of a UINT8.

hi, im trying to write a game that uses SDL_Net and i was wondering if its
possible that packets i send could get broken up so the server would recieve
lets say a >UINT16 in 2 packets, each made up of a UINT8.
Depends if you use TCP or UDP… UDP is a packet oriented unreliable
protocol, so your packets might arrive in disorder or not arrive at all.
While TCP is a reliable stream protocol, that means the bytes will arrive
and will arrive in the correct order but a bunch of bytes sent could arrive
in several bunchs, or, several small chunks might end up being received as
one large bunch of bytes… It s very easy to write functions for TCP to
work with packets though…

I proposed to add those simple functions in SDL_net a while ago but well,
seems like it went unnoticed… :frowning:

Hope this helps,
Ga?tan.

yeah it helps alot, thanx.> ----- Original Message -----

From: ged@bugfactory.org (Gaetan de Menten)
To:
Sent: Monday, July 22, 2002 6:50 PM
Subject: Re: [SDL] SDL_Net

hi, im trying to write a game that uses SDL_Net and i was wondering if
its
possible that packets i send could get broken up so the server would
recieve
lets say a >UINT16 in 2 packets, each made up of a UINT8.
Depends if you use TCP or UDP… UDP is a packet oriented unreliable
protocol, so your packets might arrive in disorder or not arrive at all.
While TCP is a reliable stream protocol, that means the bytes will
arrive
and will arrive in the correct order but a bunch of bytes sent could
arrive
in several bunchs, or, several small chunks might end up being received as
one large bunch of bytes… It s very easy to write functions for TCP to
work with packets though…

I proposed to add those simple functions in SDL_net a while ago but well,
seems like it went unnoticed… :frowning:

Hope this helps,
Ga?tan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

im not sure if this is the place to ask, but im trying to get SDL_Net
working with mingw and im havin some problems. I got SDL working with it
with -lSDL -lSDLmain so i figured when i added SDL_Net i could do -lSDL_Net
but its not workin. I get the error:

ld.exe: cannot open -lSDL_Net: No such file or directory

i downloaded the .dll file from the binary distro. The binary distro for
msvc comes with a .lib…im wondering if the other version should come with
a .a?

At 07:36 PM 9/16/02 -0700, you wrote:

i downloaded the .dll file from the binary distro. The binary distro for
msvc comes with a .lib…im wondering if the other version should come with
a .a?

I suggest compiling it from source, with msys. But ymmv.

Hello folks.

Does anyone have a tutoria on how to use SDL_Net. I’m quite new on this
kind of stuff and the examples are still a little confuse to me.

Thank you.

Adilson.

Hi,

I have a problem using SDL_Net.
I have a working client and server application, but the problem is this when one
of the two programs chrashes, the other chrashes also. It does mention an Broken
pipe when it chrashes, but i can’t find a way to prevent that from happening.
The code is like this:

// value is an int* and sckt is an TCPSocket*
int result(0);
result=SDLNet_TCP_Send(sckt,value,4);
std::cout<<“output1:”<<result;
if(result>0){
result=SDLNet_TCP_Send(sckt,value2,4);
std::cout<<“output2:”<<result;
}

When i look at the output of the programm it says:
output1:4
followed by the Broken Pipe.(it seems like the second ‘Send’ always causes the
Broken Pipe)

Though i thought it would be like
output1:0

If that where the case i could skip sending the second time, avoiding the Broken
pipe. Now i wonder is there a way to avoid the broken pipe, or to check wether a
socket is closed/unavaible or not.

You know I searched your email up and down Arjen. I thought to myself,
“Surely, this Arjen hasn’t omitted his operating system, the version of
SDL_net he’s using, and other vital information.” But alas, you have
omitted this information.

Now I’m unfamiliar with SDL_net myself, but I’m willing to bet it comes
with some test applications. Why don’t you use those and see if you can
replicate this erroneous behavior?

even though you’ve demonstrated considerable ineptitude by your glaring
omissions of important information, that the problem you’re
experiencing isn’t your fault.

I know enough to give you a probable solution, but I am reluctant to
post it since I do not know the internals of SDL_net. Could an SDL_net
expert perhaps come along and provide this guy with some help?.. that
is, after he posts his specific circumstances (SDL_net version, OS,
etc)

Good luck with your problem Arjentina, don’t let that nation debt get
you down!From my experience with unix networking, I’d be willing to bet that

On Sep 21, 2004, at 4:25 PM, Arjen wrote:

Hi,

I have a problem using SDL_Net.
I have a working client and server application, but the problem is
this when one
of the two programs chrashes, the other chrashes also. It does mention
an Broken
pipe when it chrashes, but i can’t find a way to prevent that from
happening.
The code is like this:

// value is an int* and sckt is an TCPSocket*
int result(0);
result=SDLNet_TCP_Send(sckt,value,4);
std::cout<<“output1:”<<result;
if(result>0){
result=SDLNet_TCP_Send(sckt,value2,4);
std::cout<<“output2:”<<result;
}

When i look at the output of the programm it says:
output1:4
followed by the Broken Pipe.(it seems like the second ‘Send’ always
causes the
Broken Pipe)

Though i thought it would be like
output1:0

If that where the case i could skip sending the second time, avoiding
the Broken
pipe. Now i wonder is there a way to avoid the broken pipe, or to
check wether a
socket is closed/unavaible or not.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Donny Viszneki <smirk thebuicksix.com> writes:

You know I searched your email up and down Arjen. I thought to myself,
“Surely, this Arjen hasn’t omitted his operating system, the version of
SDL_net he’s using, and other vital information.” But alas, you have
omitted this information.

Well you’re right I thought I had included that information but it
seems like it got lost somewhere in between, I guess something went
wrong while submitting ( ? )

Programming language :

  • C++

System-environment:

  • Linux on i686(Mandrake 10, kernel 2.6.3-15mdk)
  • gcc 3.3.2
  • sdl 1.2.7-2mdk
  • sdl_net 1.2.5-1

I hope this information is sufficient enough

Thx in advance,
Arjen

From your description, it’s probably a reasonable impression that
you’re on a Linux or Unix system. In general when you set up a
connection between two programs using pipes, the premature death of one
process can cause a “SIGPIPE” signal to be sent to the other. By
default, pretty much any signal will kill the process that receives it,
giving that “Broken pipe” error in this case. You may want to do a
little research on signal handlers in C and C++. Here is one place that
might have some good info:

http://www.delorie.com/gnu/docs/glibc/libc_487.html

Adding signal handlers can make debugging much easier for things like
that. For example, instead of crashing when it receives a SIGPIPE, your
program could log a set of helpful messages and continue running or exit
more gracefully.

Hope that helps.
Ryan

Arjen wrote:>Hi,

I have a problem using SDL_Net.
I have a working client and server application, but the problem is this when one
of the two programs chrashes, the other chrashes also. It does mention an Broken
pipe when it chrashes, but i can’t find a way to prevent that from happening.
The code is like this:

// value is an int* and sckt is an TCPSocket*
int result(0);
result=SDLNet_TCP_Send(sckt,value,4);
std::cout<<“output1:”<<result;
if(result>0){
result=SDLNet_TCP_Send(sckt,value2,4);
std::cout<<“output2:”<<result;
}

When i look at the output of the programm it says:
output1:4
followed by the Broken Pipe.(it seems like the second ‘Send’ always causes the
Broken Pipe)

Though i thought it would be like
output1:0

If that where the case i could skip sending the second time, avoiding the Broken
pipe. Now i wonder is there a way to avoid the broken pipe, or to check wether a
socket is closed/unavaible or not.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I deliberately didn’t describe SIGPIPE because it didn’t sound like
this guy was capable of fixing the problem in SDL_net. Moreover, on
Linux you can also get SIGPIPE (or EPIPE) from a TCP/IP socket.

Since Ryan has dived into the pool of POSIX sockets programming, I’ll
elaborate a little bit more.

You’re getting SIGPIPE because SDL_net clearly isn’t set up to handle
SIGPIPE. This is clearly a problem (as I stated in my last email) with
SDL_net and not with your code. Unless you’re educated (or perhaps
daring) enough to try and write a patch, then by all means go ahead and
try. But I simply assumed (perhaps wrongfully so) that you weren’t
ready to take on that task.

I doubt there is any solution to your problem that doesn’t involve
altering the SDL_net source code. The easiest solution would be to ask
for EPIPEs instead of SIGPIPEs, and check errno, but then you’d need to
know the file descriptors for all sockets opened. (Actually I’d be
willing to bet there’s a very easy way to do that - I just don’t know
what it is.) Another way might be to have a global variable that is
used to tell your program when a SIGPIPE has been delivered, this
variable can be set by your SIGPIPE handler (which I think Ryan
described how to do) and you can check that to see if the connection
has disappeared as a result of the SIGPIIPE. Both strategies (EPIPE and
SIGPIPE) are going to be similar in implementation. Be aware that you
may want to conditionally compile this code based on the operating
system (use preprocessor codes to see if you’re on a POSIX system.)On Sep 22, 2004, at 12:05 PM, Ryan Hanlon wrote:

From your description, it’s probably a reasonable impression that
you’re on a Linux or Unix system. In general when you set up a
connection between two programs using pipes, the premature death of
one process can cause a “SIGPIPE” signal to be sent to the other. By
default, pretty much any signal will kill the process that receives
it, giving that “Broken pipe” error in this case. You may want to do
a little research on signal handlers in C and C++. Here is one place
that might have some good info:

http://www.delorie.com/gnu/docs/glibc/libc_487.html

Adding signal handlers can make debugging much easier for things like
that. For example, instead of crashing when it receives a SIGPIPE,
your program could log a set of helpful messages and continue running
or exit more gracefully.

Hope that helps.
Ryan

Arjen wrote:

Hi,

I have a problem using SDL_Net.
I have a working client and server application, but the problem is
this when one
of the two programs chrashes, the other chrashes also. It does
mention an Broken
pipe when it chrashes, but i can’t find a way to prevent that from
happening.
The code is like this:

// value is an int* and sckt is an TCPSocket*
int result(0);
result=SDLNet_TCP_Send(sckt,value,4);
std::cout<<“output1:”<<result;
if(result>0){
result=SDLNet_TCP_Send(sckt,value2,4);
std::cout<<“output2:”<<result;
}

When i look at the output of the programm it says:
output1:4
followed by the Broken Pipe.(it seems like the second ‘Send’ always
causes the
Broken Pipe)

Though i thought it would be like
output1:0

If that where the case i could skip sending the second time, avoiding
the Broken
pipe. Now i wonder is there a way to avoid the broken pipe, or to
check wether a
socket is closed/unavaible or not.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl