Im trying to complete a very simple thing - open a socket and send string "hello" every second.
If I use send command then I receive one "hello" string on the server, but then the execution hangs in hci_event_handler() on the following line:
if (tSLInformation.usEventOrDataReceived != 0)
Seems like its expecting some data back?
If I use a sendto command without connect then it doesn't hang but I also receive nothing on the server.
My final task is to continuously stream data to the open socket. Anybody has an idea on whats going wrong there?
Here is my code:
int socket_handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
tSocketAddr.
sa_family = AF_INET;
unsigned long port;
port = htons(1234);
memcpy(&tSocketAddr.sa_data[0], &port, sizeof(unsigned short));
// IP addr of server
unsigned long ulIpAddr;
ulIpAddr = htonl(3232281170);
//192.168.0.1
memcpy(&tSocketAddr.sa_data[2], (unsigned char*)&ulIpAddr, 4);
//SysCtlDelay(10000);
char sendmsg[5]="Hello";
if(socket_handle!=-1)
{
connect(socket_handle, &tSocketAddr,
sizeof(tSocketAddr));
P1DIR |=BIT3;
while(1)
{
//sendto(socket_handle, &sendmsg, sizeof(sendmsg), 0, &tSocketAddr, sizeof(sockaddr));
send(socket_handle, &sendmsg,
sizeof(sendmsg), 0);
P1OUT ^=BIT3;
__delay_cycles(1000000);
}
}