54 ADAM-4577 User’s Manual
Example:
SOCKADDR_IN Dst4577Addr;
SOCKET Dst4577Sock;
char RxData[10];
memset(&Dst4577Addr, 0, sizeof(SOCKADDR_IN));
Dst4577Addr..sin_family = AF_INET;
Dst4577Addr..sin_addr.s_addr = inet_addr(“10.0.0.1”);
//Indicate the IP Address of ADAM-4577 that you want to connect.//
Dst4577Addr..sin_port = htons(5201);
// Indicate which port of ADAM-4577 you want to access//
// TCP port no. of Port1 = TCP port +1//
// TCP port no. of Port2 = TCP port +2//
Dst4577Sock = socket(AF_INET, SOCK_STREAM, 0));
// ADAM-4577 creates the TCP socket//
connect(Dst4577Sock, (sockaddr *)&Dst4577Addr,
sizeof(Dst4577Addr));
//Connect to the ADAM-4577//
send(Dst4577Sock, “0123456789”, 10, 0);
//Send data “0123456789” to the port of ADAM-4577//
recv(Dst4577Sock, RxData, 10, 0);
//Receive the data from the port of ADAM-4577//
closesocket(Dst4577Sock);
//Disconnect from the ADAM-4577//
Kommentare zu diesen Handbüchern