Searching a library for client server game programming with SDL

Hello list,

I found SDL_net, and I read some documents about sockets, what is the name
of the most habitual library for this?. I use C/C++ under Linux.

I’ve heard enet is reasonable

http://enet.bespin.org/On Tue, Sep 8, 2009 at 1:50 AM, Altair Linux wrote:

Hello list,

I found SDL_net, and I read some documents about sockets, what is the name
of the most habitual library for this?. I use C/C++ under Linux.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

2009/9/8 Micah Brening <micah.brening at gmail.com>:

Altair Linux <altairlinux gmail.com> writes:

Hello list,I found SDL_net, and I read some documents about sockets, what is
the name of the most habitual library for this?. I use C/C++ under Linux.

SDL_Net is good for the most part. ?If you want to use UDP you’ll have to
implement your own transmission control and serialization.

ENet is good, but is UDP only. ?I’m not certain if it supports Game Lobby
Discovery (broadcasting)

I hear Raknet is good. ?Haven’t used it though.

I WISH I could get grapple to work on windows, but the requirement of openssh
has messed that up for me. ?(never had luck with openssh on mingw32)

ENet includes a portability wrapper for socket APIs. That’ll help even for TCP.
They have their own mailing list and IRC channel if you need help or
want more info on features.

I don’t know about this.

I am in a personal proyect in a future version (I don’t how many time in the
future) I need to create a client - server comunication. I read only a basic
tutorial about sockets in linux. This is the reason I searching any library.

I read the documentation of sdl_net but I think is maybe confused. I not
understand how to put a host, a port number and data to send, etc.

  1.  SDLNet_Init is to initialize the SDL_net library
    
  2.  SDLNet_ResolveHost is to resolve hostname to IP
    
  3.  SDLNet_TCP_Open is to open a connection using the IP in step 2
    
  4.  SDLNet_TCP_Send is to send data
    

You can find in the SDL net documentation
http://jcatki.no-ip.org:8080/SDL_net/

On Behalf Of Altair LinuxFrom: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org]
Sent: Wednesday, September 09, 2009 1:08 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Cc: sdl at libsdl.org
Subject: Re: [SDL] Searching a library for client server game
programmingwith SDL

I don’t know about this.

I am in a personal proyect in a future version (I don’t how many time in
the future) I need to create a client - server comunication. I read only
a basic tutorial about sockets in linux. This is the reason I searching
any library.

I read the documentation of sdl_net but I think is maybe confused. I not
understand how to put a host, a port number and data to send, etc.

2009/9/9 Altair Linux :

I read the documentation of sdl_net but I think is maybe confused. I not
understand how to put a host, a port number and data to send, etc.

After SDL_Init(), do this:

if (SDLNet_Init() == -1) {
printf(“Error initializing SDL_Net: %s\n”, SDLNet_GetError());
exit(1);
}

Before SDL_Quit(), do this:

SDLNet_Quit();

To get an IP address from a host name, do this (for www.example.com:80):

IPaddress ipaddress;
if (SDLNet_ResolveHost(&ipaddress, “www.example.com”, 80) == -1) {
printf(“Unable to resolve host address: %s\n”, SDLNet_GetError());
exit(2);
}

To open a TCP connection to an IP address, do this:

TCPsocket tcpsock;
tcpsock=SDLNet_TCP_Open(&ipaddress);
if (!tcpsock) {
printf(“Unable to connect to host: %s\n”, SDLNet_GetError());
exit(3);
}

To send data over a TCP connection, do this:

char* data = “hello world”, tmp;
int length = strlen(data)+1;
int bytessent = 0, result;
tmp = data;

do {
result = SDLNet_TCP_Send(tcpsock, tmp, length - bytessent);
if (result == 0) {
printf(“TCP connection closed unexpectedly\n”);
exit(4);
}
bytessent += result;
tmp += result;
} while (bytessent < length);

To check if data is available from a TCP connection, do this:

if (SDLNet_SocketReady(tcpsock)) {
// do stuff
}

To receive data from a TCP connection, do this:

int buffer_size = 1024, bytesreceived;
char buffer[buffer_size+1];
bytesreceived = SDLNet_TCP_Recv(tcpsock, buffer, buffer_size);
if (bytesreceived < 0) {
printf(“Error receiving data: %s\n”, SDLNet_GetError());
exit(5);
}
if (bytesreceived == 0) {
printf(“TCP connection closed unexpectedly\n”);
exit(6);
}
buffer[bytesreceived] = ‘\0’;
printf(“Received data: %s\n”, buffer);

To close a TCP connection, do this:

SDLNet_TCP_Close(tcpsock);

you can find additional documentation here:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_net

Hi.

If you haven’t, do read Beej’s network guide. It is a great
introduction to network programming. http://beej.us/guide/bgnet/

If you keep the SDL_net API documentation open
(http://www.libsdl.org/cgi/docwiki.cgi/SDL_net) you should be able to
translate the calls between the raw socket API and SDL_net (most of
the time, SDL_net is easier =).On Wed, Sep 9, 2009 at 7:07 AM, Altair Linux wrote:

I don’t know about this.

I am in a personal proyect in a future version (I don’t how many time in the
future) I need to create a client - server comunication. I read only a basic
tutorial about sockets in linux. This is the reason I searching any library.

I read the documentation of sdl_net but I think is maybe confused. I not
understand how to put a host, a port number and data to send, etc.

Hi,

i haven’t understood exactly what you are seeking, but with basic
knowledge how the socket system works, you won’t get far. This is a
discussion you might be interested in:

A few months ago i searched for a multi-platform OSS C++ network library
with IPv6 support (SDL_net lacks IPv6), but haven’t got time to evaluate my
findings. Not mentioned in the discussion above are
Endpoint: http://endpoint.sourceforge.net/
Simple and Fast Multimedia Library: http://www.sfml-dev.org/

Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the internet,
you won’t get far. UDP is not very NAT/Masquerading friendly.

Hello list,

I found SDL_net, and I read some documents about sockets, what is the
nameOn Tue, 8 Sep 2009 07:50:47 +0200, Altair Linux wrote:
of the most habitual library for this?. I use C/C++ under Linux.


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

Most fast paced online games use UDP. TCP has some properties which
make it less suitable for real time transport. Unless you are talking
about hosting issues? Most NATs allow port forwarding for UDP and TCP,
so I don’t see how TCP would be superior?On Wed, Sep 9, 2009 at 12:33 PM, Christoph Nelles wrote:

Hi,

Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the internet,
you won’t get far. UDP is not very NAT/Masquerading friendly.

2009/9/9 Christoph Nelles

Hi,

i haven’t understood exactly what you are seeking, but with basic
knowledge how the socket system works, you won’t get far. This is a
discussion you might be interested in:
http://stackoverflow.com/questions/118945/best-c-c-network-library

A few months ago i searched for a multi-platform OSS C++ network library
with IPv6 support (SDL_net lacks IPv6), but haven’t got time to evaluate my
findings. Not mentioned in the discussion above are
Endpoint: http://endpoint.sourceforge.net/
Simple and Fast Multimedia Library: http://www.sfml-dev.org/

Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the internet,
you won’t get far. UDP is not very NAT/Masquerading friendly.

Hello list,

I found SDL_net, and I read some documents about sockets, what is the
name
of the most habitual library for this?. I use C/C++ under Linux.


Christoph Nelles

E-Mail : evilazrael at evilazrael.de
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

"Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the internet,
you won’t get far. UDP is not very NAT/Masquerading friendly."
Please stop spreading nonsense like this. UDP is used in nearly all fast
paced action games on the pc. Raknet has a reliability layer so even if it
does not support TCP it can emulate it.> On Tue, 8 Sep 2009 07:50:47 +0200, Altair Linux wrote:

Most fast paced online games use UDP. TCP has some properties which
make it less suitable for real time transport. Unless you are talking
about hosting issues? Most NATs allow port forwarding for UDP and TCP,
so I don’t see how TCP would be superior?

You need:

  • Understanding what NAT/Masquerading is
  • Access/Right/Knowledge to/for/of the router
  • A router which is capable of the necessary changes
  • Information about required ports, etc
  • Games often use fixed ports, making it impossible to use more than a
    client behind a router
  • as a developer. Willingness to accept lost packets and design a fault
    tolerant software

Not many consumers meet the above requirements. I estimate 95 - 99% of the
standard mainstream can’t do this. Take DirectPlay, it’s a nightmare if you
are in charge of a router.

Hi,

Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the
internet,On Wed, 9 Sep 2009 12:42:18 +0100, Brian <brian.ripoff at gmail.com> wrote:
On Wed, Sep 9, 2009 at 12:33 PM, Christoph Nelles<@Christoph_Nelles> wrote:

you won’t get far. UDP is not very NAT/Masquerading friendly.


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

Hi,

Please stop spreading nonsense like this. UDP is used in nearly all
fast
paced action games on the pc. Raknet has a reliability layer so even if
it
does not support TCP it can emulate it.

Name a few. Oh, leave every one out, which you can’t play because you are
in a masqueraded LAN often found in in dormatories.On Wed, 9 Sep 2009 12:44:12 +0100, liam mail <liam.list at googlemail.com> wrote:


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

2009/9/9 Christoph Nelles

Hi,

Please stop spreading nonsense like this. UDP is used in nearly all
fast
paced action games on the pc. Raknet has a reliability layer so even if
it
does not support TCP it can emulate it.

Name a few. Oh, leave every one out, which you can’t play because you are
in a masqueraded LAN often found in in dormatories.


Christoph Nelles

E-Mail : evilazrael at evilazrael.de
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Let me first point out this is the SDL mailing list.
Secondly are you abaraba? He has been doing the rounds lately
http://gafferongames.com/2009/09/04/the-return-of-the-timestep-crusader/
Thirdly your need for me to mention which games use UDP indicates you have
no knowledge on the matter, if you would like to explore this more via a
conversation please post to the gamedev.net network forum, the igda network
mailing list or any other game networking forum/list and I am sure people
will be more than happy to dispel your beliefs. Remember that I am saying
UDP is used for fast paced against games, do you think TCP is good for this
type of game? I mean a client is going to sit there and wait whilst the
kernel buffers your messages because one went a stray? Not forgetting that
this missing message may not longer be of any relavance to the game state. I
am not saying TCP can not be used only it is the exsecption to the norm.
Finally you do you mention DirectPlay an API which has not been available in
an SDK release for over two years because … well … it was pathetic.> On Wed, 9 Sep 2009 12:44:12 +0100, liam mail <@liam_mail> wrote:

Understanding what NAT/Masquerading is

I have that =)

  • Access/Right/Knowledge to/for/of the router
  • A router which is capable of the necessary changes

This is true. But TCP doesn’t help you here

  • Information about required ports, etc

Not usually a problem - netstat etc will tell you what ports a server uses.

  • Games often use fixed ports, making it impossible to use more than a
    client behind a router

That depends on the program, its not a universal rule. If you are
making your own game you can make configurable ports.

as a developer. Willingness to accept lost packets and design a fault
tolerant software

If you are using UDP, this is already part of the contract

Name a few. Oh, leave every one out, which you can’t play because you are
in a masqueraded LAN often found in in dormatories.

The question remains - TCP solves this problem how? What is the alternative?

Btw. if RAKnet is really UDP-only then forget it. UDP is fine and fast
within LANs, but if you plan to make your game playable on the internet,
you won’t get far. UDP is not very NAT/Masquerading friendly.

Excuse me? You’ve got a way better chance of getting UDP packets through a
NAT router, thanks to STUN/TURN/ICE. I would guess UDP is the norm for
online first person shooters.

GregoryOn Wed, 9 Sep 2009, Christoph Nelles wrote: