Advantech EDG-4516+ Manual de usuario Pagina 82

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 112
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 81
EDG-4508+/4516+ User Manual 70
Example (EDG-4508+U):
SOCKADDR_IN HostAddr;
SOCKET HostSock;
SOCKADDR_IN ClntAddr;
SOCKET ClntSock;
int ClntAddrLen;
char RxData[256];
memset(&HostAddr, 0, sizeof(SOCKADDR_IN));
HostAddr..sin_family = AF_INET;
HostAddr..sin_addr.s_addr = INADDR_ANY;
HostAddr.sin_port = htons(5201);
//Define the TCP port of host PC. It's the same as the value that you key-
in it in the "Peer for Receiving Data" item of configuration utility//
HostSock = socket(AF_INET, SOCK_STREAM, 0);
// Create the socket of TCP on the Host//
bind(HostSock,(sockaddr *)&HostAddr, sizeof(HostAddr));
listen(HostSock, 1);
ClntAddrLen=sizeof(ClntAddr);
ClntSock = accept(HostSock, (sockaddr *)&ClntAddr, &ClntAddrLen);
//The host PC accepts the connection request from the EDG-4508+U/
EDG-4516+U //
recv(ClntSock, RxData, 256, 0);
//Receive the data from the port of EDG-4508+U/EDG-4516+U //
closesocket(ClntSock);
//Disconnect from the EDG-4508+U/EDG-4516+U //
Vista de pagina 81
1 2 ... 77 78 79 80 81 82 83 84 85 86 87 ... 111 112

Comentarios a estos manuales

Sin comentarios