Programmbeispiel für ein verbundenes Gerät
int nErrorStatus;
int Dmykeyin;
int Closeflag;
int socketno;
int main()
{
WORD wVersionRequested=MAKEWORD(1,1);
WSADATA wsaData;
int length;
unsigned char s_buf[BUF_SIZE];
unsigned char r_buf[BUF_SIZE];
int rbuf_idx;
int recv_size;
struct sck_inf sc;
struct sockaddr_in hostdata;
struct sockaddr_in aj71e71;
void Sockerror(int);
unsigned long ulCmdArg ;
sc.my_addr.s_addr=htonl(INADDR_ANY);
sc.my_port=htons(0);
sc.aj_addr.s_addr=inet_addr(„192.0.1.253");
sc.aj_port=htons(0x2000);
Closeflag=FLAG_OFF;
nErrorStatus=WSAStartup(wVersionRequested,&wsaData); // Winsock Ini tial pro cess ing
if(nErrorStatus!=SOCK_OK) {
}
printf(„Winsock Ver sion is %ld.%ld\n",HIBYTE(wsaData.wVersion), LOBYTE(wsaData.wVersion));
printf(„AJ_test Start\n");
socketno=socket(AF_INET,SOCK_STREAM,0);
if(socketno==INVALID_SOCKET){
}
(Fort set zung auf der nächs ten Seite)
A - 52
Sockerror(ERROR_INI TIAL);
return(SOCK_NG);
Sockerror(ERROR_SOCKET);
return(SOCK_NG);
// Error infor ma tion stor age vari able
// Dummy key input
// Con nec tion com ple tion flag
// Winsock Ver 1.1 request
// Com mu ni ca tion data length
// Send buffer
// Receive buffer
// Receive data stor age head index
// Num ber of receive data
// Exter nal device side data
// E71 side data
// Error han dling func tion
// Non-block ing mode set ting flag
// Exter nal device side IP address
// Exter nal device side port num ber
// E71 side IP address (C00001FDH)
// E71 side port num ber
// Con nec tion com ple tion flag off
// Error han dling
// Cre ate socket for TCP/IP
// Error han dling
MITSUBISHI ELECTRIC
An hang