- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
on the web I found an example of a UDP-server but it doens't seem to compile. It sais it doesn't know the right directory. Could you tell me what the problem is?! # include "lwip/sockets.h"# include <sys/types.h># include <netinet/in.h># include <stdio.h> int main(void) { int sockfd, addrlen; char buffer[100]; int no_of_bytes; struct sockaddr_in addr; struct sockaddr_in their_addr; //create a socket if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { printf("error:socket creation\n"); } printf(" Socket fd:%d \n", sockfd); addr.sin_port = htons(666); addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; memset(&(addr.sin_zero), 0, 8); //Bind the socket to the port printf("binding socket....\n"); if ( bind(sockfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { printf("error:Binding\n"); } printf("Socket bound\n"); addrlen = sizeof(struct sockaddr); if((no_of_bytes = recvfrom( sockfd, buffer, sizeof(buffer), 0, (struct sockaddr *) &their_addr, &addrlen)) == -1) { printf("error in receiving from %s \n", inet_ntoa(their_addr.sin_addr)); printf(" %d\n", no_of_bytes); exit(0); } else { printf("Received: %s\n", buffer); } upper_lower(buffer); sendto(sockfd, buffer, sizeof(buffer), 0, (struct sockaddr *) &their_addr, addrlen); close(sockfd); return 0; } It seems fine by me, and I changed some stuff, but the compiler doesn't recognize the folders. Cheers, DannyLink Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, what excuse is the compiler giving you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by mike desimone@Nov 1 2005, 03:14 PM so, what excuse is the compiler giving you?
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=10726)
--- quote end ---
--- Quote End --- It's saying that it doesn't recognize the file "in.h", but I don't know how to make a path to that file. I am using a blank project, cause I don't need all of the other examples. I just a few simpel things to establish a connection. But this seems to be written in Visual C. Could I use this with the MicroC/OS-II?! cheers, Danny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Danny,
For the necessary includes, and other stuff you have to take care of, please view either the simple socket server example or the web server example. These are both good places to start, even though they're both based upon TCP. You need to understand one (or both) of these examples prior to proceeding! The only difference, in your case, is the tasks you'll be kicking off with sys_thread_new(). You could simply add a new task calling a function which wraps your code. Best Regards, - slacker
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page