#include "config.h"
#include <netinet/in.h>
#include <sys/socket.h>
Implements the parts of the vmdsock.h interface needed for IMD communication.
- Author
- Martin Hoefling, Carsten Kutzner ckutz.nosp@m.ne@g.nosp@m.wdg.d.nosp@m.e
For more information, see https://www-s.ks.uiuc.edu/Research/vmd/imd/ for general IMD information and https://www-s.ks.uiuc.edu/Research/vmd/imd/code/imdapi.tar.gz for the IMD reference implementation and API.
int imd_sock_listen |
( |
IMDSocket * |
sock | ) |
|
Set socket to listening state.
Prints out an error message if unsuccessful.
- Parameters
-
- Returns
- 0 if successful.
IMDSocket* imdsock_accept |
( |
IMDSocket * |
sock | ) |
|
Accept incoming connection and redirect to client socket.
Prints out an error message if unsuccessful.
- Parameters
-
- Returns
- IMD socket if successful, NULL otherwise.
int imdsock_bind |
( |
IMDSocket * |
sock, |
|
|
int |
port |
|
) |
| |
Bind the IMD socket to address and port.
Prints out an error message if unsuccessful. If port == 0, bind() assigns a free port automatically.
- Parameters
-
sock | The IMD socket. |
port | The port to bind to. |
- Returns
- 0 if successful.
IMDSocket* imdsock_create |
( |
| ) |
|
Create an IMD master socket.
- Returns
- The IMD socket if successful. Otherwise prints an error message and returns NULL.
int imdsock_destroy |
( |
IMDSocket * |
sock | ) |
|
Close the socket and free the sock struct memory.
Writes an error message if unsuccessful.
- Parameters
-
- Returns
- 1 on success, or 0 if unsuccessful.
int imdsock_getport |
( |
IMDSocket * |
sock, |
|
|
int * |
port |
|
) |
| |
Get the port number used for IMD connection.
Prints out an error message if unsuccessful.
- Parameters
-
sock | The IMD socket. |
port | The assigned port number. |
- Returns
- 0 if successful, an error code otherwise.
int imdsock_read |
( |
IMDSocket * |
sock, |
|
|
char * |
buffer, |
|
|
int |
length |
|
) |
| |
Read from socket.
- Parameters
-
sock | The IMD socket. |
buffer | Buffer to put the read data. |
length | Number of bytes to read. |
- Returns
- The number of bytes read, or -1 for errors.
void imdsock_shutdown |
( |
IMDSocket * |
sock | ) |
|
Shutdown the socket.
- Parameters
-
int imdsock_tryread |
( |
IMDSocket * |
sock, |
|
|
int |
timeoutsec, |
|
|
int |
timeoutusec |
|
) |
| |
Try to read from the socket.
Time out after waiting the interval specified. Print an error message if unsuccessful.
- Parameters
-
sock | The IMD socket. |
timeoutsec | Time out seconds |
timeoutusec | Time out microseconds |
int imdsock_write |
( |
IMDSocket * |
sock, |
|
|
const char * |
buffer, |
|
|
int |
length |
|
) |
| |
Write to socket.
- Parameters
-
sock | The IMD socket. |
buffer | The data to write. |
length | Number of bytes to write. |
- Returns
- The number of bytes written, or -1.