由 sunheart 在 05-31-2004 15:07 发表:
uclinux(多线程和多进程问题)
哪位做过嵌入式uclinux??给帮个忙!!
我用arm+uclinux想实现一个服务器,实现多个客户端,当客户端连接时能给客户端发送数据,我想做成能同时给多个客户发送数据,但是我用多进程(用vfork()函数)和多线程(用pthread_create()函数)编程都不能实现,在uclinux中,由于vfork函数执行后创建子进程,此时,执行子进程,而父进程被系统锁定,所以用进程编程时不能实现的。
我用线程编写的程序在生成image时出现如下错误,谁能给我看看,我该怎么做!!
arm-elf-gcc -Os -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -I/home/sumy/uClinux-Samsung/lib/libc/include -I/home/sumy/uClinux-Samsung/lib/libm -I/home/sumy/uClinux-Samsung -fno-builtin -nostartfiles -I/home/sumy/uClinux-Samsung/linux-2.4.x/include -c -o server.o server.c
server.c:11: pthread.h: ?????????
make[2]: *** [server.o] Error 1
make[2]: Leaving directory `/home/sumy/uClinux-Samsung/user/myapp'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/sumy/uClinux-Samsung/user'
make: *** [subdirs] Error 1
救救我呀!!
谢谢先!!
sunheart
┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳
┻┳┻┳我要去撞墙清醒一下┳┻┳┻
┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳
┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻
由 renbagshoes 在 05-31-2004 22:22 发表:
看一下置顶推荐的那本书的嵌入式Linux网络功能实现部分
说明在书上,源码在这:
client.c
> PHP源码: > > * * * > >
>
> /*
> * A simple C/S mode communication example demo
> *
> * client.c
> *
> */
> #include
1<stdio.h>
2> #include <stdlib.h>
3> #include <errno.h>
4> #include <string.h>
5> #include <netdb.h>
6> #include <sys types.h="">
7> #include <netinet in.h="">
8> #include <sys socket.h="">
9>
10> #define PORT 2000
11> #define MAXDATASIZE 100
12>
13> int main ( int aront> , char * argv [])
14> {
15> int sockfd , numbytes ;
16> char buf [ MAXDATASIZE ];
17> struct hostent he ;
18> struct sockaddr_in their_addr ;
19>
20> if( argc != 2 ){
21> fprintf ( stderr , "usage: client hostname\n" );
22> exit( 1 );
23> }
24>
25> if(( he = gethostbyname ( argv [ 1 ])) == NULL ){
26> herror ( "gethostbyname" );
27> exit( 1 );
28> }
29>
30> if(( sockfd = socket ( AF_INET , SOCK_STREAM , 0 )) == - 1 ){
31> perror ( "sockfd" );
32> exit( 1 );
33> }
34>
35> their_addr . sin_family = AF_INET ;
36> their_addr . sin_port = htons ( PORT );
37> their_addr . sin_addr = *(( struct in_addr *) he . h_addr );
38> bzero (&( their_addr . sin_zero ), 8 );
39>
40> if( connect ( sockfd , ( struct sockaddr *)& their_addr , sizeof ( struct sockaddr )) == - 1 ){
41> perror ( "connect" );
42> exit( 1 );
43> }
44>
45> if(( numbytes = recv ( sockfd , buf , MAXDATASIZE , 0 )) == - 1 ){
46> perror ( "recv" );
47> exit( 1 );
48> }
49>
50> buf [ numbytes ] = '