SDDS ToolKit Programs and Libraries for C and Python
|
A simple TCP client for sending commands to a server.
This program establishes a TCP connection to a specified server and port, sends commands either from the command-line arguments or interactively from the user, and processes the server's responses. The client supports persistent connections, allowing multiple commands to be sent over a single socket until a "disconnect" command is issued.
Required | Description |
---|---|
hostname | The server's hostname or IP address. |
port | The port number on which the server is listening. |
Optional | Description |
---|---|
<command> | One or more commands to send to the server initially. |
Definition in file sddslogclient.c.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
Go to the source code of this file.
Functions | |
void | error_exit (const char *msg) |
int | process_command (char *buffer, int sockfd) |
int | main (int argc, char *argv[]) |
void error_exit | ( | const char * | msg | ) |
Definition at line 51 of file sddslogclient.c.
int main | ( | int | argc, |
char * | argv[] ) |
Definition at line 74 of file sddslogclient.c.
int process_command | ( | char * | buffer, |
int | sockfd ) |
Definition at line 57 of file sddslogclient.c.