linux epollÓÃÓÚsocket¿ØÖÆ ´úÂëʵÀý
¹ØÓÚepollʹÓ÷½·¨£º
²ÎÕÕ£º http://linux.die.net/man/4/epoll
ʵÀý´úÂ룺£¨À´×ÔÍøÉÏijÂÛ̳£©
#include <pthread.h>
#include <stdio.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#define MAX_CLIENT 101
#define PORT 3355
#define DEBUG
int listenfd;
//ÉèÖÃsocketÁ¬½ÓΪ·Ç×èÈûģʽ
void nonblock(int sockfd)
{
int opts;
opts = fcntl(sockfd, F_GETFL);
if(opts < 0)
{
perror("fcntl(F_GETFL)\n");
exit(1);
}
opts = (opts | O_NONBLOCK);
if(fcntl(sockfd, F_SETFL, opts) < 0)
{
perror("fcntl(F_SETFL)\n");
exit(1);
}
}
int main()
{
int epfd;
struct epoll_event *events;
struct epoll_event ev;
struct sockaddr_in srv;
int clifd;
int i;
int n;
int res;
char buffer[1024];
//´´½¨·þÎñÆ÷¶Ësocket
if( (listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
perror("sockfd\n");
exit(1);
}
bzero(&srv, sizeof(srv));
srv.sin_family = AF_INET;
srv.sin_addr.s_addr = htonl(INADDR_ANY);;
srv.sin_port = htons(PORT);
//·
Ïà¹ØÎĵµ£º
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
1.A. extract the install file
tar zxvf bxviewer.tar.gz
cd bxviewer
./installbxv
logout
1.B. if system can't find bxv after ur installation, you can always set
it up by hand
......
sudo apt-get build-dep firefox
Èô³öÏÖÏÂÃæµÄ´íÎó£º
²»ÄÜÂú×ãÈí¼þ°ü firefox ËùÒªÇóµÄ¹¹½¨ÒÀÀµ¹ØÏµ
Ç뽫 /etc/apt/sources.list ¸ÄΪĬÈϵÄÔ´ ÓоÍÊÇ ×°Íêϵͳºó×Ô´øµÄ£º
#deb cdrom:[Ubuntu 9.04 _Jaunty Jackalope_ - Release i386 (20090421.3)]/ jaunty main restricted
# See http://help.ubuntu ......
Linux C + + Training
Syllabus
________________________________________
1, Linux Operating System
System Environment: Ubuntu GNU / Linux, RedHat Linux AS5,
FreeBSD
Course Requirements: proficient use of commonly used Linux
/ UNIX commands.
Time: 1 week.
______________________________ ......