Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VsnetOSS Namespace Reference

Functions

INLINE int close_socket (int fd)
 
INLINE int inet_aton (const char *host, struct in_addr *inp)
 
INLINE int socket (int domain, int type, int protocol)
 
INLINE int recv (int fd, void *buf, unsigned int len, int flags)
 
INLINE void memcpy (void *dest, const void *src, int bytesize)
 
bool set_blocking (int _fd, bool isBlocking)
 

Function Documentation

INLINE int VsnetOSS::close_socket ( int  fd)

uses closesocket for WIN32, otherwise close

Definition at line 22 of file vsnet_oss.cpp.

Referenced by ServerSocket::child_disconnect(), VsnetSocketBase::close_fd(), VSPipe::closeread(), VSPipe::closewrite(), NetUIBase::createClientSocket(), and NetUIBase::createServerSocket().

23 {
24 #if defined (_WIN32) && !defined (__CYGWIN__)
25  return ::closesocket( fd );
26 
27 #else
28  return ::close( fd );
29 #endif
30 }
INLINE int VsnetOSS::inet_aton ( const char *  cp,
struct in_addr *  inp 
)

uses inet_aton if exists, otherwise inet_addr

Definition at line 32 of file vsnet_oss.cpp.

Referenced by AddressIP::AddressIP(), and NetUIBase::lookupHost().

33 {
34 #if defined (_WIN32) && !defined (__CYGWIN__)
35  inp->s_addr = ::inet_addr( host );
36  if (inp->s_addr == INADDR_NONE) return 0;
37  return 1;
38 
39 #else
40  return ::inet_aton( host, inp );
41 #endif
42 }
INLINE void VsnetOSS::memcpy ( void *  dest,
const void *  src,
int  bytesize 
)

Definition at line 65 of file vsnet_oss.cpp.

Referenced by NetBuffer::addBuffer(), NetBuffer::addChar(), GFXQuadList::AddQuad(), AddressIP::AddressIP(), NetBuffer::addString(), NetBuffer::addType(), VsnetDownload::Client::Buffer::childAppend(), PipelinedTexture::Clone(), ConvertPalette(), VsnetDownload::Server::DownloadItemBuf::copyFromFile(), CopyMemory(), GFXQuadList::DelQuad(), VsnetDownload::Server::DownloadItemBuf::DownloadItemBuf(), Mesh::Fork(), VSFileSystem::VSFile::Fscanf(), NetBuffer::getChar(), SaveNetUtil::GetSaveBuffer(), NetBuffer::getType(), getWeaponInfoFromBuffer(), NetworkCommunication::GetWebcamFromNetwork(), GFXLoadMatrixProjection(), GFXOptimizeList(), FileUtil::HashStringCompute(), heightmapTransform(), INET_getHostByName(), GFXVertexList::Init(), easyDomFactory< configNode >::LoadCalike(), Audio::OpenALSimpleSound::loadImpl(), NetUIBase::lookupHost(), main(), GFXQuadList::ModQuad(), NetBuffer::NetBuffer(), gfx_light::operator=(), AddressIP::operator=(), Audio::SoundBuffer::operator=(), PacketMem::PacketMem(), UnitFactory::parsePlanetBuffer(), SaveGame::ParseSaveGame(), PngReadFunc(), Enhancement::reactToCollision(), Audio::Stream::read(), VSFileSystem::VSFile::Read(), Muzak::readerThread(), NetworkCommunication::RecvSound(), gfx_light::ResetProperties(), Resizable< GFXColorVertex >::Resizable(), NetBuffer::resizeBuffer(), Rread(), setWeaponInfoToBuffer(), Audio::SoundBuffer::SoundBuffer(), StreamTexture::StreamTexture(), terrainTransform(), texTransform(), UnpickleAllMissions(), StarSystemGent::Vector::Vector(), VSFileSystem::VSFile::VSFile(), and GFXVertexList::VtxCopy().

66 {
67  /* If your memcpy needs a (char* src), make ifdefs and a typecast
68  * here.
69  */
70  ::memcpy( dest, src, bytesize );
71 }
INLINE int VsnetOSS::recv ( int  fd,
void *  buf,
unsigned int  len,
int  flags 
)

make recv calls easier to debug if strangeness is in calling class, otherwise no known portability issues.

Definition at line 55 of file vsnet_oss.cpp.

Referenced by VsnetDownload::Server::Manager::addCmdDownload(), INET_Read(), INET_Recv(), NetClient::loginAcctLoop(), NetClient::loginLoop(), VsnetHTTPSocket::lower_selected(), VsnetTCPSocket::lower_selected(), and NetClient::synchronizeTime().

56 {
57 #if defined (_WIN32) && !defined (__CYGWIN__)
58  int ret = ::recv( fd, (char*) buf, len, flags );
59 #else
60  int ret = ::recv( fd, buf, len, flags );
61 #endif
62  return ret;
63 }
bool VsnetOSS::set_blocking ( int  _fd,
bool  isBlocking 
)

Definition at line 73 of file vsnet_oss.cpp.

References fprintf.

Referenced by NetUIBase::createClientSocket(), VsnetSocketBase::set_block(), and VsnetSocketBase::set_nonblock().

74 {
75  if (_fd == -1)
76  return false;
77 #if !defined (_WIN32) || defined (__CYGWIN__)
78  int datato = isBlocking ? 0 : 1;
79  if (::ioctl( _fd, FIONBIO, &datato ) == -1) {
80 #if defined (_WIN32) || __GNUC__ != 2
81  ::perror( "Error fcntl : " );
82 #else
83  fprintf( stderr, "Error fcntl : " );
84 #endif
85  return false;
86  }
87 #else
88  unsigned long datato = isBlocking ? 0 : 1;
89  if (::ioctlsocket( _fd, FIONBIO, &datato ) != 0) {
90 #if defined (_WIN32) || __GNUC__ != 2
91  ::perror( "Error fcntl : " );
92 #else
93  fprintf( stderr, "Error fcntl : " );
94 #endif
95  return false;
96  }
97 #endif
98  return true;
99 }
INLINE int VsnetOSS::socket ( int  domain,
int  type,
int  protocol 
)

ensures that the error return value is -1 and nothing else

Definition at line 44 of file vsnet_oss.cpp.

Referenced by mmoc::connectTo(), NetUIBase::createClientSocket(), NetUIBase::createServerSocket(), commandI::execute(), INET_ConnectTo(), INET_listen(), Music::Music(), and mmoc::ParseRemoteInput().

45 {
46  int ret = ::socket( domain, type, protocol );
47 #if defined (_WIN32) && !defined (__CYGWIN__)
48  if (ret == INVALID_SOCKET) return -1;
49 #else
50  if (ret < 0) return -1;
51 #endif
52  return ret;
53 }