|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#ifndef BSOCKET_H_INCLUDED
|
|
Packit Service |
c5cf8c |
#define BSOCKET_H_INCLUDED
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef __cplusplus
|
|
Packit Service |
c5cf8c |
extern "C" {
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpidi_ch3_conf.h"
|
|
Packit Service |
c5cf8c |
#include "mpichconf.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* sockaddr_in (Internet) */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_NETINET_IN_H
|
|
Packit Service |
c5cf8c |
#include <netinet/in.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WINSOCK2_H
|
|
Packit Service |
c5cf8c |
#include <winsock2.h>
|
|
Packit Service |
c5cf8c |
#include <windows.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_SYS_SOCKET_H
|
|
Packit Service |
c5cf8c |
#include <sys/socket.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_SYS_SELECT_H
|
|
Packit Service |
c5cf8c |
#include <sys/select.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_NETINET_TCP_H
|
|
Packit Service |
c5cf8c |
#include <netinet/tcp.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef SOCKET_ERROR
|
|
Packit Service |
c5cf8c |
#define SOCKET_ERROR -1
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef ADDR_ANY
|
|
Packit Service |
c5cf8c |
#define ADDR_ANY 0
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifndef INADDR_ANY
|
|
Packit Service |
c5cf8c |
#define INADDR_ANY 0
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WINDOWS_SOCKET
|
|
Packit Service |
c5cf8c |
#define bfd_close closesocket
|
|
Packit Service |
c5cf8c |
#define bfd_read(a,b,c) recv(a,b,c,0)
|
|
Packit Service |
c5cf8c |
#define bfd_write(a,b,c) send(a,b,c,0)
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define bfd_close close
|
|
Packit Service |
c5cf8c |
#define bfd_read(a,b,c) read(a,b,c)
|
|
Packit Service |
c5cf8c |
#define bfd_write(a,b,c) write(a,b,c)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WINSOCK2_H
|
|
Packit Service |
c5cf8c |
#ifndef socklen_t
|
|
Packit Service |
c5cf8c |
typedef int socklen_t;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#ifndef socklen_t
|
|
Packit Service |
c5cf8c |
#define socklen_t int
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WINSOCK2_H
|
|
Packit Service |
c5cf8c |
#define B_VECTOR WSABUF
|
|
Packit Service |
c5cf8c |
#define B_VECTOR_LEN len
|
|
Packit Service |
c5cf8c |
#define B_VECTOR_BUF buf
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_SYS_UIO_H
|
|
Packit Service |
c5cf8c |
#include <sys/uio.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#define B_VECTOR struct iovec
|
|
Packit Service |
c5cf8c |
#define B_VECTOR_LEN iov_len
|
|
Packit Service |
c5cf8c |
#define B_VECTOR_BUF iov_base
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#define B_VECTOR_LIMIT 16
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define BFD_INVALID_SOCKET -1
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* This was ifdef NO_BSOCKETS but should have been USE_BSOCKETS */
|
|
Packit Service |
c5cf8c |
#ifndef USE_BSOCKETS
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define bfd_set fd_set
|
|
Packit Service |
c5cf8c |
#define BFD_CLR(bfd, s) FD_CLR((unsigned int)bfd,s)
|
|
Packit Service |
c5cf8c |
#define BFD_ZERO(s) FD_ZERO(s)
|
|
Packit Service |
c5cf8c |
#define BFD_SET(bfd, s) FD_SET((unsigned int)bfd,s)
|
|
Packit Service |
c5cf8c |
#define BFD_ISSET(bfd, s) FD_ISSET((unsigned int)bfd,s)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define BFD_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define bcopyset(dest, src) *(dest) = *(src)
|
|
Packit Service |
c5cf8c |
#define bget_fd(bfd) bfd
|
|
Packit Service |
c5cf8c |
#define bclr(bfd, s) FD_CLR((unsigned int)bfd, s)
|
|
Packit Service |
c5cf8c |
#define bset(bfd, s) FD_SET((unsigned int)bfd, s)
|
|
Packit Service |
c5cf8c |
#define bsocket(family, type, protocol) socket(family, type, protocol)
|
|
Packit Service |
c5cf8c |
#define bbind(bfd, servaddr, servaddr_len) bind(bfd, servaddr, servaddr_len)
|
|
Packit Service |
c5cf8c |
#define blisten(bfd, backlog) listen(bfd, backlog)
|
|
Packit Service |
c5cf8c |
#define bsetsockopt(bfd, level, optname, optval, optlen) setsockopt(bfd, level, optname, optval, optlen)
|
|
Packit Service |
c5cf8c |
#define baccept(bfd, cliaddr, clilen) accept(bfd, cliaddr, clilen)
|
|
Packit Service |
c5cf8c |
#define bconnect(bfd, servaddr, servaddr_len) connect(bfd, servaddr, servaddr_len)
|
|
Packit Service |
c5cf8c |
#define bselect(maxfds, readbfds, writebfds, execbfds, tv) select(maxfds, readbfds, writebfds, execbfds, tv)
|
|
Packit Service |
c5cf8c |
#define bwrite(bfd, ubuf, len) bfd_write(bfd, ubuf, len)
|
|
Packit Service |
c5cf8c |
#define bread(bfd, ubuf, len) bfd_read(bfd, ubuf, len)
|
|
Packit Service |
c5cf8c |
#define bclose(bfd) bfd_close(bfd)
|
|
Packit Service |
c5cf8c |
#define bgetsockname(bfd, name, namelen) getsockname(bfd, name, namelen)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else /* #ifndef USE_BSOCKETS */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
typedef struct BFD_Buffer_struct BFD_Buffer;
|
|
Packit Service |
c5cf8c |
typedef struct bfd_set {
|
|
Packit Service |
c5cf8c |
fd_set set;
|
|
Packit Service |
c5cf8c |
int n;
|
|
Packit Service |
c5cf8c |
BFD_Buffer *p[FD_SETSIZE];
|
|
Packit Service |
c5cf8c |
} bfd_set;
|
|
Packit Service |
c5cf8c |
/*#define BFD_CLR(bfd, s) FD_CLR(bget_fd(bfd), & (s) -> set)*/
|
|
Packit Service |
c5cf8c |
#define BFD_CLR(bfd, s) bclr(bfd, s)
|
|
Packit Service |
c5cf8c |
#define BFD_ZERO(s) { FD_ZERO(& (s) -> set); (s) -> n = 0; }
|
|
Packit Service |
c5cf8c |
#define BFD_SET(bfd, s) bset(bfd , s)
|
|
Packit Service |
c5cf8c |
#define BFD_ISSET(bfd, s) FD_ISSET(bget_fd(bfd), & (s) -> set)
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
#define bfd_set fd_set
|
|
Packit Service |
c5cf8c |
#define BFD_CLR(bfd, set) FD_CLR(bget_fd(bfd), set)
|
|
Packit Service |
c5cf8c |
#define BFD_ZERO(set) FD_ZERO(set)
|
|
Packit Service |
c5cf8c |
#define BFD_SET(bfd, set) FD_SET(bget_fd(bfd), set)
|
|
Packit Service |
c5cf8c |
#define BFD_ISSET(bfd, set) FD_ISSET(bget_fd(bfd), set)
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define BFD_MAX(a,b) (((bget_fd(a)) > (bget_fd(b))) ? (a) : (b))
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* bsockets.c */
|
|
Packit Service |
c5cf8c |
void bcopyset(bfd_set * dest, bfd_set * src);
|
|
Packit Service |
c5cf8c |
unsigned int bget_fd(int bfd);
|
|
Packit Service |
c5cf8c |
void bset(int bfd, bfd_set * s);
|
|
Packit Service |
c5cf8c |
void bclr(int bfd, bfd_set * s);
|
|
Packit Service |
c5cf8c |
int bsocket_init(void);
|
|
Packit Service |
c5cf8c |
int bsocket_finalize(void);
|
|
Packit Service |
c5cf8c |
int bsocket(int, int, int);
|
|
Packit Service |
c5cf8c |
int bbind(int, const struct sockaddr *, socklen_t);
|
|
Packit Service |
c5cf8c |
int blisten(int, int);
|
|
Packit Service |
c5cf8c |
int bsetsockopt(int, int, int, const void *, socklen_t);
|
|
Packit Service |
c5cf8c |
int baccept(int, struct sockaddr *, socklen_t *);
|
|
Packit Service |
c5cf8c |
int bconnect(int, const struct sockaddr *, socklen_t);
|
|
Packit Service |
c5cf8c |
int bread(int, char *, int);
|
|
Packit Service |
c5cf8c |
int breadwrite(int, int, char *, int, int *, int *);
|
|
Packit Service |
c5cf8c |
int breadvwrite(int, int, B_VECTOR *, int, int *, int *);
|
|
Packit Service |
c5cf8c |
int bwrite(int, char *, int);
|
|
Packit Service |
c5cf8c |
int bclose(int);
|
|
Packit Service |
c5cf8c |
int bclose_all(void);
|
|
Packit Service |
c5cf8c |
int bgetsockname(int bfd, struct sockaddr *name, int *namelen);
|
|
Packit Service |
c5cf8c |
int bselect(int maxfds, bfd_set * readbfds, bfd_set * writebfds, bfd_set * execbfds,
|
|
Packit Service |
c5cf8c |
struct timeval *tv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* #else #ifndef USE_BSOCKETS */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int bsocket_init(void);
|
|
Packit Service |
c5cf8c |
int bsocket_finalize(void);
|
|
Packit Service |
c5cf8c |
int breadv(int, B_VECTOR *, int);
|
|
Packit Service |
c5cf8c |
int bwritev(int, B_VECTOR *, int);
|
|
Packit Service |
c5cf8c |
int bmake_nonblocking(int);
|
|
Packit Service |
c5cf8c |
int bmake_blocking(int);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int beasy_create(int *bfd, int port, unsigned long addr);
|
|
Packit Service |
c5cf8c |
int beasy_connect(int bfd, char *host, int port);
|
|
Packit Service |
c5cf8c |
int beasy_connect_timeout(int bfd, char *host, int port, int seconds);
|
|
Packit Service |
c5cf8c |
int beasy_accept(int bfd);
|
|
Packit Service |
c5cf8c |
int beasy_closesocket(int bfd);
|
|
Packit Service |
c5cf8c |
int beasy_get_sock_info(int bfd, char *name, int *port);
|
|
Packit Service |
c5cf8c |
int beasy_get_ip_string(char *ipstring);
|
|
Packit Service |
c5cf8c |
int beasy_get_ip(unsigned long *ip);
|
|
Packit Service |
c5cf8c |
int beasy_receive(int bfd, char *buffer, int len);
|
|
Packit Service |
c5cf8c |
int beasy_receive_timeout(int bfd, char *buffer, int len, int timeout);
|
|
Packit Service |
c5cf8c |
int beasy_receive_some(int bfd, char *buffer, int len);
|
|
Packit Service |
c5cf8c |
int beasy_send(int bfd, char *buffer, int length);
|
|
Packit Service |
c5cf8c |
int beasy_getlasterror(void);
|
|
Packit Service |
c5cf8c |
int beasy_error_to_string(int error, char *str, int length);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef __cplusplus
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#endif /* BSOCKET_H_INCLUDED */
|