OpenJPEG  2.4.0
Macros | Functions
sock_manager.c File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sock_manager.h"

Macros

#define FCGI_stdout   stdout
 
#define FCGI_stderr   stderr
 
#define logstream   stderr
 

Functions

SOCKET open_listeningsocket (uint16_t port)
 open listening socket More...
 
SOCKET accept_socket (SOCKET listening_socket)
 accept a new connection to the listenning socket More...
 
void send_stream (SOCKET connected_socket, const void *stream, OPJ_SIZE_T length)
 send data stream to client More...
 
void * receive_stream (SOCKET connected_socket, OPJ_SIZE_T length)
 receive data stream to client More...
 
OPJ_SIZE_T receive_line (SOCKET connected_socket, char *p)
 receive a string line (ending with '
') from client More...
 
char * receive_string (SOCKET connected_socket)
 receive a string line (ending with '
') from client, return malloc string More...
 
int close_socket (SOCKET sock)
 close socket More...
 

Macro Definition Documentation

#define FCGI_stderr   stderr
#define FCGI_stdout   stdout
#define logstream   stderr

Function Documentation

SOCKET accept_socket ( SOCKET  listening_socket)

accept a new connection to the listenning socket

Parameters
listening_socketlistenning socket
Returns
connected socket (-1 if error occurs)

Referenced by accept_connection(), and aux_streaming().

int close_socket ( SOCKET  sock)

close socket

Parameters
[in]sockclosing socket
Returns
0 if succeed, -1 if failed

Referenced by aux_streaming(), close_aux_transport(), handle_clientreq(), open_listeningsocket(), and terminate_dec_server().

SOCKET open_listeningsocket ( uint16_t  port)

open listening socket

Parameters
portopening port number
Returns
new socket

References close_socket(), and FCGI_stderr.

Referenced by init_aux_transport(), and init_dec_server().

OPJ_SIZE_T receive_line ( SOCKET  connected_socket,
char *  buf 
)

receive a string line (ending with '
') from client

Parameters
[in]connected_socketfile descriptor of the connected socket
[out]bufstring to be stored
Returns
red size

References FCGI_stderr.

Referenced by handle_PNMreqMSG(), identify_clientmsg(), receive_JPIPstream(), and receive_string().

void* receive_stream ( SOCKET  connected_socket,
OPJ_SIZE_T  length 
)

receive data stream to client

Parameters
[in]connected_socketfile descriptor of the connected socket
[in]lengthlength of the receiving stream
Returns
pointer to the data stream (memory allocated), NULL if failed

References FCGI_stderr.

Referenced by receive_JPIPstream(), and recv_ack().

char* receive_string ( SOCKET  connected_socket)

receive a string line (ending with '
') from client, return malloc string

Parameters
[in]connected_socketfile descriptor of the connected socket
Returns
pointer to the string (memory allocated)

References BUF_LEN, and receive_line().

Referenced by handle_CIDreqMSG(), handle_dstCIDreqMSG(), handle_JP2saveMSG(), handle_PNMreqMSG(), handle_SIZreqMSG(), handle_TIDreqMSG(), handle_XMLreqMSG(), and identify_cid().

void send_stream ( SOCKET  connected_socket,
const void *  stream,
OPJ_SIZE_T  length 
)

send data stream to client

Parameters
[in]connected_socketfile descriptor of the connected socket
[in]streamdata stream
[in]lengthlength of data stream

References FCGI_stderr.

Referenced by aux_streaming(), response_signal(), send_IDstream(), send_PNMstream(), send_SIZstream(), and send_XMLstream().