hi all,
i am using ns9360 board and NetOS6.3 version for writing an application in C for data exchange between ns9360 board and a PC with VB application
Here i am able to create a socket and bind it and i am getting the status for sendto command as 4 bytes i.e i am sending “5555”…but the problem is on VB side i could n’t get the data.Nothing happening in VB side.I am getting correct return type for sendto command but still why i am not getting the data on VB side at the same time whenever i tried to send the data fron VB to NetOS board also data not receiving in Board side.
I am giving the source code at the bottom i have written for the reference…
what could be the problem pls any one can suggest me on this …or mail me at kotireddy@bhelrnd.co.in
thanks®ards
Kotireddy
UDP code on NetOS6.3 in C is:
int sFd,idd,bytes;
struct sockaddr_in serverAddr; /* server’s socket address /
struct sockaddr_in clientAddr; / client’s socket address /
int sockAddrSize; / size of socket address structure */
char ack[1024]=“5555”;
sFd=socket(AF_INET,SOCK_DGRAM,0);
if (sFd<0)
printf("
socket creation failed
“);
else
printf(”
socket creation success
");
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons (6000);
serverAddr.sin_addr.s_addr = htonl (INADDR_ANY);
idd=bind(sFd,&serverAddr,sizeof(serverAddr));
if (idd==0)
printf(" udp bind success
“);
else if (idd==-1)
printf(”
udp bind failure
“);
clientAddr.sin_family = AF_INET;
clientAddr.sin_port = htons (6000);
clientAddr.sin_addr.s_addr = htonl(“192.168.12.33”);
sockAddrSize=sizeof(clientAddr);
while(1)
{
bytes = sendto (sFd, ack, strlen (ack), 0, &clientAddr, sizeof(clientAddr));
if (bytes==-1)
{
printf(”
ERROR in Send :%s",ack);
}
else
{
printf("
%s %d",ack,bytes);
}
}
my VB side code on a PC with XP-sp2 is:
WINSOCK1 object settings on VB form are:protocol is UDPPROTOCOL
remotehostip:192.168.12.33
remoteport:6000
localport:6000
Private Sub Form_Load()
With Winsock1
.RemotePort = 6000 ’ Port to connect to.
.Bind 6000 ’ Bind to the local port.
End With
end sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim NewLine As String
Winsock1.GetData str
end sub