EasyManua.ls Logo

SystemBase Portbase-3010 - Page 115

SystemBase Portbase-3010
118 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Portbase User Guide
//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);
}
//Creates the socket.
if ((sock = socket(PF_INET, SOCK_STREAM, 0))<0)
{
printf("cant open socket!!\n");
exit(0);
}
bzero((char *)&server_addr, sizeof(server_addr));
//Fills the structure.
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = inet_addr(argv[1]);
server_addr.sin_port = htons(4001);
//Connects to the server.
if (connect(sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0)
{
printf("cant connect to server!!\n");
exit(0);
}
while(1)
{
SendData();
sleep(3);
115

Table of Contents