Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Functions | Variables
Xtranssock.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>

Go to the source code of this file.

Classes

struct  _Sockettrans2dev

Defines

#define NUMSOCKETFAMILIES   (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))

Typedefs

typedef struct _Sockettrans2dev Sockettrans2dev

Functions

static int TRANS() SocketSelectFamily (char *family)
static int TRANS() SocketINETGetAddr (XtransConnInfo ciptr)
static int TRANS() SocketINETGetPeerAddr (XtransConnInfo ciptr)
static XtransConnInfo TRANS() SocketOpen (int i, int type)
static int TRANS() SocketSetOption (XtransConnInfo ciptr, int option, int arg)
static int TRANS() SocketBytesReadable (XtransConnInfo ciptr, BytesReadable_t *pend)
static int TRANS() SocketRead (XtransConnInfo ciptr, char *buf, int size)
static int TRANS() SocketWrite (XtransConnInfo ciptr, char *buf, int size)
static int TRANS() SocketReadv (XtransConnInfo ciptr, struct iovec *buf, int size)
static int TRANS() SocketWritev (XtransConnInfo ciptr, struct iovec *buf, int size)
static int TRANS() SocketDisconnect (XtransConnInfo ciptr)

Variables

static Sockettrans2dev Sockettrans2devtab []

Class Documentation

struct _Sockettrans2dev

Definition at line 139 of file Xtranssock.c.

Class Members
int devcltsname
int devcotsname
int family
int protocol
char * transname

Define Documentation

#define NUMSOCKETFAMILIES   (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))

Definition at line 160 of file Xtranssock.c.


Typedef Documentation


Function Documentation

static int TRANS() SocketBytesReadable ( XtransConnInfo  ciptr,
BytesReadable_t pend 
) [static]

Definition at line 1600 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketBytesReadable) (%x,%d,%x)\n",
       ciptr, ciptr->fd, pend);

#ifdef WIN32
    return ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
#else
#if (defined(i386) && defined(SYSV) && !defined(SCO)) || defined(_SEQUENT_)
    return ioctl (ciptr->fd, I_NREAD, (char *) pend);
#else
    return ioctl (ciptr->fd, FIONREAD, (char *) pend);
#endif /* i386 && SYSV || _SEQUENT_ */
#endif /* WIN32 */
}
static int TRANS() SocketDisconnect ( XtransConnInfo  ciptr) [static]

Definition at line 1686 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketDisconnect) (%x,%d)\n", ciptr, ciptr->fd, 0);

    return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
}
static int TRANS() SocketINETGetAddr ( XtransConnInfo  ciptr) [static]

Definition at line 248 of file Xtranssock.c.

{
    struct sockaddr_in      sockname;
    int                     namelen = sizeof sockname;

    PRMSG (3,"TRANS(SocketINETGetAddr) (%x)\n", ciptr, 0, 0);

    if (getsockname (ciptr->fd,(struct sockaddr *) &sockname, &namelen) < 0)
    {
       PRMSG (1,"TRANS(SocketINETGetAddr): getsockname() failed: %d\n",
           EGET(),0, 0);
       return -1;
    }

    /*
     * Everything looks good: fill in the XtransConnInfo structure.
     */

    if ((ciptr->addr = (char *) malloc (namelen)) == NULL)
    {
        PRMSG (1,
           "TRANS(SocketINETGetAddr): Can't allocate space for the addr\n",
           0, 0, 0);
        return -1;
    }

    ciptr->family = sockname.sin_family;
    ciptr->addrlen = namelen;
    memcpy (ciptr->addr, &sockname, ciptr->addrlen);

    return 0;
}
static int TRANS() SocketINETGetPeerAddr ( XtransConnInfo  ciptr) [static]

Definition at line 291 of file Xtranssock.c.

{
    struct sockaddr_in      sockname;
    int                     namelen = sizeof(sockname);

    PRMSG (3,"TRANS(SocketINETGetPeerAddr) (%x)\n", ciptr, 0, 0);

    if (getpeername (ciptr->fd, (struct sockaddr *) &sockname, &namelen) < 0)
    {
       PRMSG (1,"TRANS(SocketINETGetPeerAddr): getpeername() failed: %d\n",
           EGET(), 0, 0);
       return -1;
    }

    /*
     * Everything looks good: fill in the XtransConnInfo structure.
     */

    if ((ciptr->peeraddr = (char *) malloc (namelen)) == NULL)
    {
        PRMSG (1,
          "TRANS(SocketINETGetPeerAddr): Can't allocate space for the addr\n",
          0, 0, 0);
        return -1;
    }

    ciptr->peeraddrlen = namelen;
    memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);

    return 0;
}
static XtransConnInfo TRANS() SocketOpen ( int  i,
int  type 
) [static]

Definition at line 328 of file Xtranssock.c.

{
    XtransConnInfo   ciptr;

    PRMSG (3,"TRANS(SocketOpen) (%d,%d)\n", i, type, 0);

    if ((ciptr = (XtransConnInfo) calloc (
       1, sizeof(struct _XtransConnInfo))) == NULL)
    {
       PRMSG (1, "TRANS(SocketOpen): malloc failed\n", 0, 0, 0);
       return NULL;
    }

    if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
       Sockettrans2devtab[i].protocol)) < 0
#ifndef WIN32
#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
       || ciptr->fd >= TRANS_OPEN_MAX
#endif
#endif
      ) {
       PRMSG (1, "TRANS(SocketOpen): socket() failed for %s\n",
           Sockettrans2devtab[i].transname, 0, 0);

       free ((char *) ciptr);
       return NULL;
    }

#ifdef TCP_NODELAY
    if (Sockettrans2devtab[i].family == AF_INET)
    {
       /*
        * turn off TCP coalescence for INET sockets
        */

       int tmp = 1;
       setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,
           (char *) &tmp, sizeof (int));
    }
#endif

    return ciptr;
}

Here is the call graph for this function:

static int TRANS() SocketRead ( XtransConnInfo  ciptr,
char *  buf,
int  size 
) [static]

Definition at line 1622 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketRead) (%d,%x,%d)\n", ciptr->fd, buf, size);

#ifdef WIN32
    return recv ((SOCKET)ciptr->fd, buf, size, 0);
#else
    return read (ciptr->fd, buf, size);
#endif /* WIN32 */
}

Here is the call graph for this function:

static int TRANS() SocketReadv ( XtransConnInfo  ciptr,
struct iovec *  buf,
int  size 
) [static]

Definition at line 1658 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketReadv) (%d,%x,%d)\n", ciptr->fd, buf, size);

    return READV (ciptr, buf, size);
}
static int TRANS() SocketSelectFamily ( char *  family) [static]

Definition at line 223 of file Xtranssock.c.

{
    int     i;

    PRMSG (3,"TRANS(SocketSelectFamily) (%s)\n", family, 0, 0);

    for (i = 0; i < NUMSOCKETFAMILIES;i++)
    {
        if (!strcmp (family, Sockettrans2devtab[i].transname))
           return i;
    }

    return -1;
}
static int TRANS() SocketSetOption ( XtransConnInfo  ciptr,
int  option,
int  arg 
) [static]

Definition at line 677 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketSetOption) (%d,%d,%d)\n", ciptr->fd, option, arg);

    return -1;
}
static int TRANS() SocketWrite ( XtransConnInfo  ciptr,
char *  buf,
int  size 
) [static]

Definition at line 1640 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketWrite) (%d,%x,%d)\n", ciptr->fd, buf, size);

#ifdef WIN32
    return send ((SOCKET)ciptr->fd, buf, size, 0);
#else
    return write (ciptr->fd, buf, size);
#endif /* WIN32 */
}

Here is the call graph for this function:

static int TRANS() SocketWritev ( XtransConnInfo  ciptr,
struct iovec *  buf,
int  size 
) [static]

Definition at line 1672 of file Xtranssock.c.

{
    PRMSG (2,"TRANS(SocketWritev) (%d,%x,%d)\n", ciptr->fd, buf, size);

    return WRITEV (ciptr, buf, size);
}

Variable Documentation

Initial value:
 {



 





 
}

Definition at line 147 of file Xtranssock.c.