beautypg.com

Solvline PB2xxxUG User Manual

Page 102

background image

If the user designates the IP address of a specific Portbase and start the program, “This is
LoopBack Data!” is repeatedly transmitted at 3 second intervals and received data will be
displayed on screen.

5) How to Run

Plug the first Portbase serial port to the loopback connector. (The port is connected to

socket 4001.)

If you run the program, message “This is LoopBack Data! ” returns and is repeatedly

displayed on screen.

6) Source Code

//Inserts the necessary header files.

#include

#include

#include

#include

#include

//Inserts the necessary global variable, and declares the function.

int sock;//Variable for saving the socket handle.

void SendData(void);

void GetData(void);

//Creates the main function and calls the function.

int main(int argc, char *argv[])

{

char buff[1024];

int count = 0;

pid_t pid;

int ff;

struct sockaddr_in server_addr;

if (argc != 2)//Outputs a message if it is not the input format.

{

printf("How to run : %s Porter IP \n", argv[0]);

exit(0);

102