SDL_net add feature to bind definite local ip

Unfortunately it breaks off the binary compatibility

try it, the mac opentrasport version is not tested (i not have mac :-/)

See ya!--------------------------------------

Index: SDL_net.h

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDL_net.h,v
retrieving revision 1.22
diff -u -r1.22 SDL_net.h
— SDL_net.h 7 Aug 2003 01:34:23 -0000 1.22
+++ SDL_net.h 30 Aug 2003 20:52:24 -0000
@@ -99,10 +99,30 @@
*/
extern DECLSPEC const char * SDLCALL SDLNet_ResolveIP(IPaddress *ip);

+//
+/* ICMP network API patch by Emanuele “Goul_duKat” Trevisio
<@Goul_duKat>*/
+/
/
+#ifdef ACTIVATE_SDLNET_ICMP
+
+//Open a ICMP channel for send echo
+extern DECLSPEC int SDLCALL SDLNet_ICMP_Open(void);
+
+//Close the ICMP channel
+extern DECLSPEC int SDLCALL SDLNet_ICMP_Close(void);
+
+//Fast count rtt and hop (in win32 not need the open of the ICMP channel)
+extern DECLSPEC int SDLCALL SDLNet_ICMP_fast_routeping(Uint32 ip,Uint32
maxhop,Uint32* hop,Uint32* rtt);
+
+//Normal echo whit ttl for traceroute facilities
+//tristate function return -1 on error, 1 no error 2 TTL expired (add for
trace facilities)
+extern DECLSPEC int SDLCALL SDLNet_ICMP_echo(Uint32 ip,Uint8 ttl,Uint32
timeout,Uint32* rtt,Uint32* ipr);

+#endif
//
/* TCP network API */
/
/
+#define SDLNET_OPEN_NORMAL_MODE 0
+#define SDLNET_OPEN_BINDLOCAL 1

typedef struct _TCPsocket *TCPsocket;

@@ -114,7 +134,10 @@
SDLNet_ResolveHost() are already in the correct form).
The newly created socket is returned, or NULL if there was an error.
*/
-extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip);
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>
/
+extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip,Uint8
open_mode);

/* Accept an incoming connection on the given server socket.
The newly created socket is returned, or NULL if there was an error.
@@ -186,7 +209,10 @@
internally in network (big endian) byte order, in addresses, etc.
This allows other systems to send to this socket via a known port.
*/
-extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port);
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>
/
+extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(IPaddress *ip,Uint8
open_mode);

/* Bind the address ‘address’ to the requested channel on the UDP socket.
If the channel is -1, then the first unbound channel will be bound with
Index: SDLnet.c

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnet.c,v
retrieving revision 1.11
diff -u -r1.11 SDLnet.c
— SDLnet.c 30 Aug 2003 17:32:47 -0000 1.11
+++ SDLnet.c 30 Aug 2003 20:52:25 -0000
@@ -20,7 +20,7 @@
slouken at libsdl.org
*/

-/* $Id: SDLnet.c,v 1.11 2003/08/30 17:32:47 slouken Exp $ /
+/
$Id: SDLnet.c,v 1.10 2003/07/23 05:08:43 slouken Exp $ */

#include <string.h>

@@ -280,6 +280,16 @@
{
if ( !SDLNet_started ) {
#ifdef __USE_W32_SOCKETS
+#ifdef _WINSOCK2_H

  • /* Start up the windows networking */
  • WORD version_wanted = MAKEWORD(2,2);
  • WSADATA wsaData;
  • if ( WSAStartup(version_wanted, &wsaData) != 0 ) {
  • SDLNet_SetError(“Couldn’t initialize Winsock 2.0\n”);
  • return(-1);
  • }
    +#else
    /* Start up the windows networking */
    WORD version_wanted = MAKEWORD(1,1);
    WSADATA wsaData;
    @@ -288,6 +298,7 @@
    SDLNet_SetError(“Couldn’t initialize Winsock 1.1\n”);
    return(-1);
    }
    +#endif //_WINSOCK2_H
    #else
    ;
    #endif
    Index: SDLnetTCP.c
    ===================================================================
    RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetTCP.c,v
    retrieving revision 1.11
    diff -u -r1.11 SDLnetTCP.c
    — SDLnetTCP.c 13 Apr 2002 14:50:37 -0000 1.11
    +++ SDLnetTCP.c 30 Aug 2003 20:52:25 -0000
    @@ -278,7 +278,10 @@
    Now endpoint is created in Async mode.
    01/02/20 )
    */
    -TCPsocket SDLNet_TCP_Open(IPaddress *ip)
    +//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
    +/add open mode to listen local definite ip in IPaddress
    +patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>
    /
    +TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode )
    {
    EndpointRef dummy = NULL;

@@ -287,7 +290,7 @@
return NULL;

// Determin whether bind locally, or connect to remote

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) )
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) && open_mode ==
    SDLNET_OPEN_NORMAL_MODE )
    {
    // ######## Connect to remote
    OTResult stat;
    @@ -399,6 +402,8 @@
    else
    {
    // ######## Bind locally
  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility
  • TBind bindReq;
    InetAddress inAddr;

@@ -431,7 +436,7 @@
}

// Bind the socket

  • OTInitInetAddress(&inAddr, ip->port, 0 );
  • OTInitInetAddress(&inAddr, ip->port, ip->host );
    inAddr.fAddressType = AF_INET;
    bindReq.addr.len = sizeof( InetAddress );
    bindReq.addr.buf = (unsigned char*)&inAddr;
    @@ -695,7 +700,10 @@
    otherwise a TCP connection to the remote host and port is attempted.
    The newly created socket is returned, or NULL if there was an error.
    */
    -TCPsocket SDLNet_TCP_Open(IPaddress *ip)
    +//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
    +/add open mode to listen local definite ip in IPaddress
    +patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>
    /
    +TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode)
    {
    TCPsocket sock;
    struct sockaddr_in sock_addr;
    @@ -715,7 +723,7 @@
    }

/* Connect to remote, or bind locally, as appropriate */

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE ) {

    // ######### Connecting to remote

@@ -734,16 +742,17 @@
} else {

// ########## Binding locally

  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility
  • memset(&sock_addr, 0, sizeof(sock_addr));
    sock_addr.sin_family = AF_INET;
  • sock_addr.sin_addr.s_addr = INADDR_ANY;
  • sock_addr.sin_addr.s_addr = ip->host;
    sock_addr.sin_port = ip->port;

    /* allow local address reuse */

  • { int yes = 1;
  • /{ int yes = 1;
    setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char
    )&yes,
    sizeof(yes));
  • }
  • }*///Dangerous and non needed settings for normal use !!!

    /* Bind the socket for listening */
    if ( bind(sock->channel, (struct sockaddr )&sock_addr,
    Index: SDLnetUDP.c
    ===================================================================
    RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetUDP.c,v
    retrieving revision 1.9
    diff -u -r1.9 SDLnetUDP.c
    — SDLnetUDP.c 14 Jun 2003 07:20:31 -0000 1.9
    +++ SDLnetUDP.c 30 Aug 2003 20:52:26 -0000
    @@ -272,7 +272,10 @@
    /
    Open a UDP network socket
    If ‘port’ is non-zero, the UDP socket is bound to a fixed local port.
    */
    -extern UDPsocket SDLNet_UDP_Open(Uint16 port)
    +//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
    +/add open mode to listen local definite ip in IPaddress
    +patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>
    /
    +extern UDPsocket SDLNet_UDP_Open(IPaddress *ip,Uint8 open_mode)
    {
    UDPsocket sock;
    #ifdef MACOS_OPENTRANSPORT
    @@ -329,18 +332,32 @@
    assigned_addr.addr.len = sizeof(assigned);
    assigned_addr.addr.buf = (UInt8 *) &assigned;

  • if ( port ) {
  • if ( ip->port ) {
    status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );
    if( status != kOTNoError )
    goto error_return;
  • OTInitInetAddress(&required, port, info.fAddress );
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )

  • OTInitInetAddress(&required, ip->port, info.fAddress );

  • else OTInitInetAddress(&required, ip->port, ip->host );
    req_addr.addr.maxlen = sizeof( required );
    req_addr.addr.len = sizeof( required );
    req_addr.addr.buf = (UInt8 *) &required;

    sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);
    } else {

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )
    sock->error = OTBind(sock->channel, nil, &assigned_addr );

  • else

  • {

  • status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );

  • if( status != kOTNoError )

  • goto error_return;
    
  • OTInitInetAddress(&required, 0, ip->host );

  • req_addr.addr.maxlen = sizeof( required );

  • req_addr.addr.len = sizeof( required );

  • req_addr.addr.buf = (UInt8 *) &required;

  • sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);

  • }
    }
    AsyncUDPPopEvent(sock);

@@ -363,13 +380,19 @@
}
#else
/* Bind locally, if appropriate */

  • if ( port )
  • //if ( ip->port ) //whit no else is broken ??? for port == 0 ???
    {
    struct sockaddr_in sock_addr;
    memset(&sock_addr, 0, sizeof(sock_addr));
    sock_addr.sin_family = AF_INET;
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )
    sock_addr.sin_addr.s_addr = INADDR_ANY;
  • sock_addr.sin_port = SDL_SwapBE16(port);
  • else

  • {

  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility

  • sock_addr.sin_addr.s_addr = ip->host;

  • }

  • sock_addr.sin_port = SDL_SwapBE16(ip->port);

    /* Bind the socket for listening */
    if ( bind(sock->channel, (struct sockaddr *)&sock_addr,

sorry for repost but i add the SDLNet_inet_ntoa for print the ip in uman
readable form …

if the function i use exist in all other platfor remove the #ifdef braches
it

See ya!-----------------------
Index: SDL_net.h

===================================================================

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDL_net.h,v

retrieving revision 1.22

diff -u -r1.22 SDL_net.h

— SDL_net.h 7 Aug 2003 01:34:23 -0000 1.22

+++ SDL_net.h 30 Aug 2003 22:11:06 -0000

@@ -99,10 +99,35 @@

*/

extern DECLSPEC const char * SDLCALL SDLNet_ResolveIP(IPaddress *ip);

+/***********************************************************************/

+/* ICMP network API patch by Emanuele “Goul_duKat” Trevisio
<@Goul_duKat>*/

+/***********************************************************************/

+#ifdef ACTIVATE_SDLNET_ICMP

+//return char* to array null terminated where are stored the printable

+//string of the host ip.

+//no thread safe function (don’t deallocate the area returned)

+extern DECLSPEC char * SDLCALL SDLNet_inet_ntoa(IPaddress *ip);

+//Open a ICMP channel for send echo

+extern DECLSPEC int SDLCALL SDLNet_ICMP_Open(void);

+//Close the ICMP channel

+extern DECLSPEC int SDLCALL SDLNet_ICMP_Close(void);

+//Fast count rtt and hop (in win32 not need the open of the ICMP channel)

+extern DECLSPEC int SDLCALL SDLNet_ICMP_fast_routeping(Uint32 ip,Uint32
maxhop,Uint32* hop,Uint32* rtt);

+//Normal echo whit ttl for traceroute facilities

+//tristate function return -1 on error, 1 no error 2 TTL expired (add for
trace facilities)

+extern DECLSPEC int SDLCALL SDLNet_ICMP_echo(Uint32 ip,Uint8 ttl,Uint32
timeout,Uint32* rtt,Uint32* ipr);

+#endif

/***********************************************************************/

/* TCP network API */

/***********************************************************************/

+#define SDLNET_OPEN_NORMAL_MODE 0

+#define SDLNET_OPEN_BINDLOCAL 1

typedef struct _TCPsocket *TCPsocket;

@@ -114,7 +139,10 @@

SDLNet_ResolveHost() are already in the correct form).

The newly created socket is returned, or NULL if there was an error.

*/

-extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip);

+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL

+/*add open mode to listen local definite ip in IPaddress

+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>*/

+extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip,Uint8
open_mode);

/* Accept an incoming connection on the given server socket.

The newly created socket is returned, or NULL if there was an error.

@@ -186,7 +214,10 @@

internally in network (big endian) byte order, in addresses, etc.

This allows other systems to send to this socket via a known port.

*/

-extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port);

+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL

+/*add open mode to listen local definite ip in IPaddress

+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>*/

+extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(IPaddress *ip,Uint8
open_mode);

/* Bind the address ‘address’ to the requested channel on the UDP socket.

If the channel is -1, then the first unbound channel will be bound with

Index: SDLnet.c

===================================================================

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnet.c,v

retrieving revision 1.11

diff -u -r1.11 SDLnet.c

— SDLnet.c 30 Aug 2003 17:32:47 -0000 1.11

+++ SDLnet.c 30 Aug 2003 22:11:06 -0000

@@ -20,7 +20,7 @@

slouken at libsdl.org

*/

-/* $Id: SDLnet.c,v 1.11 2003/08/30 17:32:47 slouken Exp $ */

+/* $Id: SDLnet.c,v 1.10 2003/07/23 05:08:43 slouken Exp $ */

#include <string.h>

@@ -280,6 +280,16 @@

{

if ( !SDLNet_started ) {

#ifdef __USE_W32_SOCKETS

+#ifdef _WINSOCK2_H

  • /* Start up the windows networking */

  • WORD version_wanted = MAKEWORD(2,2);

  • WSADATA wsaData;

  • if ( WSAStartup(version_wanted, &wsaData) != 0 ) {

  • SDLNet_SetError(“Couldn’t initialize Winsock 2.0\n”);

  • return(-1);

  • }

+#else

/* Start up the windows networking */

WORD version_wanted = MAKEWORD(1,1);

WSADATA wsaData;

@@ -288,6 +298,7 @@

SDLNet_SetError(“Couldn’t initialize Winsock 1.1\n”);

return(-1);

}

+#endif //_WINSOCK2_H

#else

;

#endif

@@ -314,6 +325,15 @@

#endif

}

}

+#ifdef WIN32

+char * SDLNet_inet_ntoa(IPaddress *ip)

+{

  • IN_ADDR address;

  • address.s_addr = ip->host;

  • return inet_ntoa(address);

+}

+#endif

/* Resolve a host name and port to an IP address in network form */

int SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port)

Index: SDLnetTCP.c

===================================================================

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetTCP.c,v

retrieving revision 1.11

diff -u -r1.11 SDLnetTCP.c

— SDLnetTCP.c 13 Apr 2002 14:50:37 -0000 1.11

+++ SDLnetTCP.c 30 Aug 2003 22:11:07 -0000

@@ -278,7 +278,10 @@

Now endpoint is created in Async mode.

01/02/20 )

*/

-TCPsocket SDLNet_TCP_Open(IPaddress *ip)

+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL

+/*add open mode to listen local definite ip in IPaddress

+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>*/

+TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode )

{

EndpointRef dummy = NULL;

@@ -287,7 +290,7 @@

return NULL;

// Determin whether bind locally, or connect to remote

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) )
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) && open_mode ==
    SDLNET_OPEN_NORMAL_MODE )

{

// ######## Connect to remote

OTResult stat;

@@ -399,6 +402,8 @@

else

{

// ######## Bind locally

  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility

TBind bindReq;

InetAddress inAddr;

@@ -431,7 +436,7 @@

}

// Bind the socket

  • OTInitInetAddress(&inAddr, ip->port, 0 );
  • OTInitInetAddress(&inAddr, ip->port, ip->host );

inAddr.fAddressType = AF_INET;

bindReq.addr.len = sizeof( InetAddress );

bindReq.addr.buf = (unsigned char*)&inAddr;

@@ -695,7 +700,10 @@

otherwise a TCP connection to the remote host and port is attempted.

The newly created socket is returned, or NULL if there was an error.

*/

-TCPsocket SDLNet_TCP_Open(IPaddress *ip)

+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL

+/*add open mode to listen local definite ip in IPaddress

+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>*/

+TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode)

{

TCPsocket sock;

struct sockaddr_in sock_addr;

@@ -715,7 +723,7 @@

}

/* Connect to remote, or bind locally, as appropriate */

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE ) {

// ######### Connecting to remote

@@ -734,16 +742,17 @@

} else {

// ########## Binding locally

  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility

memset(&sock_addr, 0, sizeof(sock_addr));

sock_addr.sin_family = AF_INET;

  • sock_addr.sin_addr.s_addr = INADDR_ANY;
  • sock_addr.sin_addr.s_addr = ip->host;

sock_addr.sin_port = ip->port;

/* allow local address reuse */

  • { int yes = 1;
  • /*{ int yes = 1;

setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes,
sizeof(yes));

  • }
  • }*///Dangerous and non needed settings for normal use !!!

/* Bind the socket for listening */

if ( bind(sock->channel, (struct sockaddr *)&sock_addr,

Index: SDLnetUDP.c

===================================================================

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetUDP.c,v

retrieving revision 1.9

diff -u -r1.9 SDLnetUDP.c

— SDLnetUDP.c 14 Jun 2003 07:20:31 -0000 1.9

+++ SDLnetUDP.c 30 Aug 2003 22:11:08 -0000

@@ -272,7 +272,10 @@

/* Open a UDP network socket

If ‘port’ is non-zero, the UDP socket is bound to a fixed local port.

*/

-extern UDPsocket SDLNet_UDP_Open(Uint16 port)

+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL

+/*add open mode to listen local definite ip in IPaddress

+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>*/

+extern UDPsocket SDLNet_UDP_Open(IPaddress *ip,Uint8 open_mode)

{

UDPsocket sock;

#ifdef MACOS_OPENTRANSPORT

@@ -329,18 +332,32 @@

assigned_addr.addr.len = sizeof(assigned);

assigned_addr.addr.buf = (UInt8 *) &assigned;

  • if ( port ) {
  • if ( ip->port ) {

status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );

if( status != kOTNoError )

goto error_return;

  • OTInitInetAddress(&required, port, info.fAddress );
  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )

  • OTInitInetAddress(&required, ip->port, info.fAddress );

  • else OTInitInetAddress(&required, ip->port, ip->host );

req_addr.addr.maxlen = sizeof( required );

req_addr.addr.len = sizeof( required );

req_addr.addr.buf = (UInt8 *) &required;

sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);

} else {

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )

sock->error = OTBind(sock->channel, nil, &assigned_addr );

  • else

  • {

  • status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );

  • if( status != kOTNoError )

  • goto error_return;

  • OTInitInetAddress(&required, 0, ip->host );

  • req_addr.addr.maxlen = sizeof( required );

  • req_addr.addr.len = sizeof( required );

  • req_addr.addr.buf = (UInt8 *) &required;

  • sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);

  • }

}

AsyncUDPPopEvent(sock);

@@ -363,13 +380,19 @@

}

#else

/* Bind locally, if appropriate */

  • if ( port )
  • //if ( ip->port ) //whit no else is broken ??? for port == 0 ???

{

struct sockaddr_in sock_addr;

memset(&sock_addr, 0, sizeof(sock_addr));

sock_addr.sin_family = AF_INET;

  • if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
    open_mode==SDLNET_OPEN_NORMAL_MODE )

sock_addr.sin_addr.s_addr = INADDR_ANY;

  • sock_addr.sin_port = SDL_SwapBE16(port);
  • else

  • {

  • if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
    compatibility

  • sock_addr.sin_addr.s_addr = ip->host;

  • }

  • sock_addr.sin_port = SDL_SwapBE16(ip->port);

/* Bind the socket for listening */

if ( bind(sock->channel, (struct sockaddr *)&sock_addr,

to test the definite binding try this test program:

you need only to telnet on localhost on port 50000 and write simple char,
the ‘Q’ quit the server program.----------------------------------------------
#include
#include “SDL.h”
#include “SDL_net.h”

using namespace std;

int SDL_main (int , char *[])
{
if(SDL_Init(0)!=0)
{
cerr << "Impossibile inizializzare SDL: " << SDL_GetError() << endl;
exit(EXIT_FAILURE);
}
if(SDLNet_Init()!=0)
{
cerr << "Impossibile inizializzare NET: " << SDLNet_GetError() << endl;
exit(EXIT_FAILURE);
}
IPaddress ip;
if(SDLNet_ResolveHost(&ip, “127.0.0.1”, 50000)!=0)
{
cerr << "Impoossibile risolvere l’host: " << SDLNet_GetError() << endl;
exit(EXIT_FAILURE);
}
TCPsocket tcp;
if(!(tcp=SDLNet_TCP_Open(&ip,SDLNET_OPEN_BINDLOCAL)))
{
cerr << "Impossibile entrare in listening: " << SDLNet_GetError() << endl;
exit(EXIT_FAILURE);
}
TCPsocket cltcp;
while ((cltcp=SDLNet_TCP_Accept(tcp))==NULL) SDL_Delay(100);
IPaddress *clip;
clip = SDLNet_TCP_GetPeerAddress(cltcp);
cout << "Nuova connessione da: " << SDLNet_ResolveIP(clip) << ‘[’ <<
SDLNet_inet_ntoa(clip) << ‘:’ << SDLNet_Read16(&clip->port) << ‘]’ << endl;
char message;
TCPsocket cltcp2;
do
{
if ((cltcp2=SDLNet_TCP_Accept(tcp))!=NULL) SDLNet_TCP_Close(cltcp2);
if(SDLNet_TCP_Recv(cltcp,&message,1)!=1)
{
cout << “Errore in ricezione, disconnesso ???” << endl;
break;
}
cout << message;
}
while (message != ‘Q’);
SDLNet_TCP_Close(cltcp);
SDLNet_TCP_Close(tcp);
SDLNet_Quit();
SDL_Quit();
return 0;
}

No one try or use this patch ???

no merging in cvs ???

no new release ???

no one add icmp for other platform on my source ??? :-/

impression, suggestion, feed-back ???

“Goul_duKat” <@Goul_duKat> ha scritto nel messaggio
news:bj38lg$mn8$1 at sea.gmane.org

No one try or use this patch ???

no merging in cvs ???

no new release ???

no one add icmp for other platform on my source ??? :-/

impression, suggestion, feed-back ???

i upped this … i need the slap on the shoulder :wink: or bad feedback to spur
(<-- this term is corret in english ??)

See ya