Hello, hope someone can help me..
I want to use my blackwidow as a client sending UDP packets to a computer (server) on my network.
On the server I run a small java program listening for udp packets on port 5003, and writing the packet content to the console when something comes in.
I did a small java program (client), sending UDP packets to port 5003, and got it to run on a different computer on my network.
With this setup the server recieves the packets as expected, and everything is nice.. This tells me that my network isn't blocking anything..
Now I want to make my BlackWidow a client sending UDP packets to the server.
I have made a short version of the udpapp.c, to make it as simple as possible. I simply just want it to send something which my server can recieve.
My problem is that the server isn't recieving anything. - My BlackWidow indicates that it's connected to the network.
I have java experience but im quite new to c/c++, so perhaps im overlooking something, or missunderstanding something..
Any ideas very appreciated...!
Here comes my short version of the udpapp:
#include "uip.h"
#include <string.h>
#include "udpapp.h"
#include "config.h"
#define STATE_INIT 0
#define STATE_LISTENING 1
#define STATE_HELLO_RECEIVED 2
#define STATE_NAME_RECEIVED 3
static struct udpapp_state s;
void dummy_app_appcall(void)
{
}
void udpapp_init(void){
uip_ipaddr_t addr;
struct uip_udp_conn *c;
uip_ipaddr(&addr, 192,168,1,108);
c = uip_udp_new(&addr, HTONS(5003));
if(c != NULL) {
uip_udp_bind(c, HTONS(0));
}
s.state = STATE_HELLO_RECEIVED;
PT_INIT(&s.pt);
}
static unsigned char parse_msg(void){
return 0;
}
static void send_request(void){
char str[] = "Hello. What is your name?\n";
memcpy(uip_appdata, str, strlen(str));
uip_send(uip_appdata, strlen(str));
}
static void send_response(void){
}
static PT_THREAD(handle_connection(void)){
PT_BEGIN(&s.pt);
send_request();
PT_END(&s.pt);
}
void udpapp_appcall(void){
handle_connection();
}