EasyManua.ls Logo

SystemBase Portbase-3010 - Page 111

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
pEdt= (CEdit *)GetDlgItem(IDC_edtIPAddress);
pEdt->GetWindowText(m_ipaddr);
// Creates the socket.
p = new CAsyncSocket;
p->Create();
// Requests a connection by the socket number 4001.
if(p->Connect((LPCSTR)m_ipaddr, 4001) == 0) {
AfxMessageBox("Connection fail");
return;
}
else AfxMessageBox("Connection success");
// Sets a timer for transmission.
SetTimer(1, 3000, NULL);
// Sets a timer for transmission.
SetTimer(2, 1, NULL);
}
// Adds a coding for transmitting and receiving data in the timer event routine.
void CSockExamDlg::OnTimer(UINT nIDEvent)
{
CEdit * pEdt = (CEdit *)GetDlgItem(IDC_edtWINDOW);
char WriteData[30] = "This is LoopBack Data !";
if(nIDEvent == 1) { //In case data is output to the socket.
p->Send(WriteData, strlen(WriteData));
}
if(nIDEvent == 2) { //In case data is inputted from the socket.
char rbuff[1000];
int nBytesRead;
nBytesRead = p->Receive(rbuff, sizeof(rbuff));
if(nBytesRead) {
111

Table of Contents