Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÏÂgetsockopt/setsockopt º¯Êý˵Ã÷

¹¦ÄÜÃèÊö£º
        »ñÈ¡»òÕßÉèÖÃ
Óëij¸öÌ×½Ó×Ö¹ØÁªµÄÑ¡ ÏѡÏî¿ÉÄÜ´æÔÚÓÚ¶à²ãЭÒé
ÖУ¬ËüÃÇ×Ü»á³öÏÖÔÚ×îÉÏÃæµÄÌ×½Ó×ֲ㡣µ±²Ù×÷Ì×½Ó×ÖÑ¡Ïîʱ£¬Ñ¡ÏîλÓڵIJãºÍÑ¡ÏîµÄÃû³Æ±ØÐë¸ø³ö¡£ÎªÁ˲Ù×÷Ì×½Ó×Ö²ãµÄÑ¡ÏӦ¸Ã ½«²ãµÄÖµÖ¸¶¨ÎªSOL_SOCKET¡£ÎªÁ˲Ù×÷ÆäËü²ãµÄÑ¡Ï¿ØÖÆÑ¡ÏîµÄºÏÊÊЭÒéºÅ±ØÐë¸ø³ö¡£ÀýÈ磬ΪÁ˱íʾһ¸öÑ¡ÏîÓÉTCP
ЭÒé½âÎö£¬²ãÓ¦¸ÃÉ趨ΪЭÒé ºÅTCP¡£
Ó÷¨£º
#include <sys/types.h>
#include <sys/socket.h>
int getsockopt
(int sock, int level, int optname, void *optval, socklen_t *optlen);
int setsockopt
(int sock, int level, int optname, const void *optval, socklen_t optlen);
²ÎÊý£º  
sock£º½«Òª±»ÉèÖûòÕß»ñÈ¡Ñ¡ÏîµÄÌ×½Ó×Ö¡£
level£ºÑ¡ÏîËùÔÚµÄЭÒé²ã¡£
optname£ºÐèÒª·ÃÎʵÄÑ¡ÏîÃû¡£
optval£º¶ÔÓÚgetsockopt()£¬Ö¸Ïò·µ»ØÑ¡ÏîÖµµÄ»º³å¡£¶ÔÓÚsetsockopt()£¬Ö¸Ïò°üº¬ÐÂÑ¡ÏîÖµµÄ»º³å¡£
optlen£º¶ÔÓÚgetsockopt()£¬×÷ΪÈë¿Ú²ÎÊýʱ£¬Ñ¡ÏîÖµµÄ×î´ó³¤¶È¡£×÷Ϊ³ö¿Ú²ÎÊýʱ£¬Ñ¡ÏîÖµµÄʵ¼Ê³¤¶È¡£¶ÔÓÚsetsockopt()£¬ÏÖÑ¡ÏîµÄ³¤¶È¡£
·µ»Ø˵Ã÷£º  
³É¹¦Ö´ÐÐʱ£¬·µ»Ø0¡£Ê§°Ü·µ»Ø-1£¬errno±»ÉèΪÒÔϵÄij¸öÖµ  
EBADF£ºsock²»ÊÇÓÐЧµÄÎļþ
ÃèÊö´Ê
EFAULT£ºoptvalÖ¸ÏòµÄÄÚ´æ²¢·ÇÓÐЧµÄ½ø³Ì¿Õ¼ä
EINVAL£ºÔÚµ÷ÓÃsetsockopt()ʱ£¬optlenÎÞЧ
ENOPROTOOPT£ºÖ¸¶¨µÄЭÒé²ã²»ÄÜʶ±ðÑ¡Ïî
ENOTSOCK£ºsockÃèÊöµÄ²»ÊÇÌ×½Ó×Ö
²ÎÊýÏêϸ˵Ã÷£º
levelÖ¸¶¨¿ØÖÆÌ×½Ó×ֵIJã´Î.¿ÉÒÔÈ¡ÈýÖÖÖµ:
1)SOL_SOCKET:ͨÓÃÌ×½Ó×ÖÑ¡Ïî.
2)IPPROTO_IP:IPÑ¡Ïî.
3)IPPROTO_TCP:TCPÑ¡Ïî.¡¡
optnameÖ¸¶¨¿ØÖƵķ½Ê½(Ñ¡ÏîµÄÃû³Æ),ÎÒÃÇÏÂÃæÏêϸ½âÊÍ¡¡
optval»ñµÃ»òÕßÊÇÉèÖÃÌ×½Ó×ÖÑ¡Ïî.¸ù¾ÝÑ¡ÏîÃû³ÆµÄÊý¾Ý
ÀàÐͽøÐÐת»»¡¡
Ñ¡ÏîÃû³Æ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ËµÃ÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Êý¾ÝÀàÐÍ
========================================================================
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SOL_SOCKET
------------------------------------------------------------------------
SO_BROADCAST¡¡¡¡¡¡¡¡¡¡¡¡ÔÊÐí·¢Ë͹㲥Êý¾Ý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_DEBUG¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÔÊÐíµ÷ÊÔ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_DONTROUTE¡¡¡¡¡¡¡¡¡¡¡¡²»²éÕÒ·ÓÉ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_ERROR¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ñµÃÌ×½


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

Linux ÐéÄâÎļþϵͳ¸Å¹Û

Linux ÐéÄâÎļþϵͳ¸Å¹Û
×÷Õß Richard Gooch <rgooch@atnf.cs.iro.au>
·­Òë albcamus <albcamus@gmail.com>
×îºó¸üÐÂ:2007 Äê 6 Ô 24 ÈÕ
°æȨ:1999, Richard Gooch
°æȨ:2005, Pekka Enberg
±¾ÎļþÒÔ GPLv2 Ðí¿É·¢·Å
[·­Òë˵Ã÷:Richard Gooch µÄÕâ·Ý Overview of ......

ÈçºÎ²é¿´linux°æ±¾


1. ²é¿´Äں˰汾ÃüÁ 
¡¡¡¡1) [root@q1test01 ~]# cat /proc/version 
¡¡¡¡ Linux version 2.6.9-22.ELsmp (bhcompile@crowe.devel.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1 SMP Mon Sep 19 18:00:54 EDT 2005 
¡¡¡¡2) [root@q1test01 ~]# uname -a 
¡¡¡¡Linux q1test0 ......

linux ²¥·ÅÉùÒôÎļþ³ÌÐò´úÂë

ÉùÒôÎļþ±ØÐëΪWave PCM unsigned 8bits mono¸ñʽ
/* the *.wav must be 8000Hz 64kbps  8bits MONO(1)*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h&g ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ