This is Unofficial EPICS BASE Doxygen Site
osdSock.c File Reference
#include <string.h>
#include <stdio.h>
#include <hostLib.h>
#include <inetLib.h>
#include "errlog.h"
#include "osiSock.h"
+ Include dependency graph for osdSock.c:

Go to the source code of this file.

Macros

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>
 

Functions

int osiSockAttach ()
 
void osiSockRelease ()
 
LIBCOM_API SOCKET epicsStdCall epicsSocketCreate (int domain, int type, int protocol)
 
LIBCOM_API int epicsStdCall epicsSocketAccept (int sock, struct sockaddr *pAddr, osiSocklen_t *addrlen)
 
LIBCOM_API void epicsStdCall epicsSocketDestroy (SOCKET s)
 
LIBCOM_API unsigned epicsStdCall ipAddrToHostName (const struct in_addr *pAddr, char *pBuf, unsigned bufSize)
 
LIBCOM_API int epicsStdCall hostToIPAddr (const char *pHostName, struct in_addr *pIPA)
 

Macro Definition Documentation

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>

Definition at line 11 of file osdSock.c.

Function Documentation

LIBCOM_API int epicsStdCall epicsSocketAccept ( int  sock,
struct sockaddr *  pAddr,
osiSocklen_t addrlen 
)

Definition at line 46 of file osdSock.c.

48 {
49  int newSock = accept ( sock, pAddr, addrlen );
50  if ( newSock < 0 ) {
51  newSock = INVALID_SOCKET;
52  }
53  return newSock;
54 }
#define INVALID_SOCKET
Definition: osdSock.h:32
LIBCOM_API SOCKET epicsStdCall epicsSocketCreate ( int  domain,
int  type,
int  protocol 
)

Definition at line 36 of file osdSock.c.

38 {
39  SOCKET sock = socket ( domain, type, protocol );
40  if ( sock < 0 ) {
41  sock = INVALID_SOCKET;
42  }
43  return sock;
44 }
#define INVALID_SOCKET
Definition: osdSock.h:32
pvd::StructureConstPtr type
int SOCKET
Definition: osdSock.h:31
LIBCOM_API void epicsStdCall epicsSocketDestroy ( SOCKET  s)

Definition at line 56 of file osdSock.c.

57 {
58  int status = close ( s );
59  if ( status < 0 ) {
60  char buf [ 64 ];
61  epicsSocketConvertErrnoToString ( buf, sizeof ( buf ) );
62  errlogPrintf (
63  "epicsSocketDestroy: failed to "
64  "close a socket because \"%s\"\n",
65  buf );
66  }
67 }
pvd::Status status
void epicsSocketConvertErrnoToString(char *pBuf, unsigned bufSize)
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
LIBCOM_API int epicsStdCall hostToIPAddr ( const char *  pHostName,
struct in_addr *  pIPA 
)

Definition at line 115 of file osdSock.c.

116 {
117  int addr = hostGetByName ( (char *) pHostName );
118  if ( addr == ERROR ) {
119  return -1;
120  }
121  pIPA->s_addr = (unsigned long) addr;
122 
123  /*
124  * success
125  */
126  return 0;
127 }
LIBCOM_API unsigned epicsStdCall ipAddrToHostName ( const struct in_addr *  pAddr,
char *  pBuf,
unsigned  bufSize 
)

Definition at line 73 of file osdSock.c.

74 {
75  int status;
76  int errnoCopy = errno;
77  unsigned len;
78 
79  if (bufSize<1) {
80  return 0;
81  }
82 
83  if (bufSize>MAXHOSTNAMELEN) {
84  status = hostGetByAddr ((int)pAddr->s_addr, pBuf);
85  if (status==OK) {
86  pBuf[MAXHOSTNAMELEN] = '\0';
87  len = strlen (pBuf);
88  }
89  else {
90  len = 0;
91  }
92  }
93  else {
94  char name[MAXHOSTNAMELEN+1];
95  status = hostGetByAddr (pAddr->s_addr, name);
96  if (status==OK) {
97  strncpy (pBuf, name, bufSize);
98  pBuf[bufSize-1] = '\0';
99  len = strlen (pBuf);
100  }
101  else {
102  len = 0;
103  }
104  }
105 
106  errno = errnoCopy;
107 
108  return len;
109 }
pvd::Status status
#define MAXHOSTNAMELEN
Definition: osdSock.h:46
int osiSockAttach ( void  )

Definition at line 27 of file osdSock.c.

28 {
29  return 1;
30 }
void osiSockRelease ( void  )

Definition at line 32 of file osdSock.c.

33 {
34 }