| << Prev | appCORE Programming Guide | Next >> |
NAME
coreNetServerPortAdd() -- listen on port for TCP connections.
SYNOPSIS
include "appcore.h" int coreNetServerPortAdd( coreNetServerPortSPEC_t* s, coreHandle_t* ph )
DESCRIPTION
The coreNetServerPortAdd() function configures netCORE to listen on the specified port. On success, netCORE will notify the caller of incoming TCP connections via netCORE events. The required EventHandler function will be called in the source thread. The caller may either accept or reject the incoming connection, via coreNetChanAccept(), or coreNetChanReject(), respectively.
PARAMETERS
s
typedef struct _core_net_server_port_spec_
{
void* UserCntxt;
The user's context, returned in each coreNetChanEventMsg_t.
coreNetAddrSPEC_t Address;
The address family and port to listen on.
coreNetOptionSPEC_t Options;
Options - The interface address may be set.
int (*EventHandler)( coreNetChanEventMsg_t* );
The user's thread local event handler. This function is called
in the context of the user's thread for incoming connections.
}
coreNetServerPortSPEC_t;
h
pointer to handle for this port. Filled in on success, else CORE_INVALID_HANDLE.
Sample Code
coreNetServerPortSPEC_t Spec;
coreHandle_t h;
// Setup port specification
bzero( &Spec, sizeof(Spec) );
Spec.UserCntxt = YourCntxt;
Spec.EventHandler = YourConnectionHandler;
// Setup IPV4 port
coreNetAddrInit(
&Spec.Address,
coreNetAddrFamilyIPV4,
INADDR_ANY,
YourPort );
// Listen on this port
coreNetServerPortAdd( &Spec, &h );
RETURN VALUE
| errno Value | Condition |
| ENOTSUP | Not supported - netCORE is not running. |
| EINVAL | Argument NULL or invalid address, or request failed. |
MULTI-THREAD SAFETY LEVEL
MT-safe.
SEE ALSO
| << Prev | appCORE Programming Guide | Next >> |