3
The oRTP library is an RTP (Realtime Transport Protocol - rfc1889) stack.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/* port_fct.h. define methods to help for portability between unix and win32 */
24
#include "rtpsession.h"
31
* this method is an utility method that calls fnctl() on UNIX or
32
* ioctlsocket on Win32.
33
* int retrun the result of the system method
35
int set_non_blocking_socket (RtpSession *session)
40
return fcntl (session->rtp.socket, F_SETFL, O_NONBLOCK);
42
unsigned long nonBlock = 1;
43
return ioctlsocket(session->rtp.socket, FIONBIO , &nonBlock);
49
* this method is an utility method that calls close() on UNIX or
50
* closesocket on Win32.
51
* int retrun the result of the system method
54
int close_socket(gint sock)
59
int close_socket(SOCKET sock)
61
return closesocket(sock);
68
* getSocketError() return a string describing the error
71
char *getSocketError()
73
int error = WSAGetLastError ();
78
case WSANOTINITIALISED: return "Windows sockets not initialized : call WSAStartup";
79
case WSAEADDRINUSE: return "Local Address already in use";
80
case WSAEADDRNOTAVAIL: return "The specified address is not a valid address for this machine";
81
// case WSAEFAULT: return "";
82
// case WSAEINPROGRESS: return "";
83
case WSAEINVAL: return "The socket is already bound to an address.";
84
case WSAENOBUFS: return "Not enough buffers available, too many connections.";
85
case WSAENOTSOCK: return "The descriptor is not a socket.";
86
case WSAECONNRESET: return "Connection reset by peer";
97
sprintf (buf,"Error code : %d", error);
108
// Use UNIX inet_aton method
110
int inet_aton (const char * cp, struct in_addr * addr)
112
unsigned long retval;
114
retval = inet_addr (cp);
116
if (retval == INADDR_NONE)
122
addr->S_un.S_addr = retval;