How to start a network listener.
For network communication testing purposes we recommend the Freeware
Hercules SETUP utility https://www.hw-group.com/software/hercules-setup-utility
Possible listener protocol types are :
- TCP
- UDP
- TLS
Example:
int running = 1;
#interrupt IV_TCP // this ist the type of interrupt haendler
void isr_tcp( int port, int sd, char *data, int datalen )
{
/* port - TCP port in this case 4711
/* sd - socket descriptor for response
/* data - pointer to data
/* datalen - the length of received data
/* make something with the data */
printf("Received data : %s , size %d \n", data, datalen);
/* send data back to client */
swrite(sd, data, datalen, 1000);
running = 0;
}
int main
(void)
{
/* open listener on port 4711 */
int sd = sopen(TCP,4711);
/* main loop */
while(running){}
sclose(sd);
return 0;
}