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

linuxÏÂtcp·þÎñÆ÷Ô´ÂëʾÀý

#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
struct _NSS_HEADER
{
unsigned short ProtocolVersion; /* ЭÒé°æ±¾ÐÅÏ¢ */
unsigned short MsgType; /* ÏûÏ¢ÀàÐÍ */
unsigned short TransactionNo; /* ´«Êä±àºÅ */
unsigned short PacketLength; /* Êý¾Ý°ü³¤¶È,°üÀ¨Header */
}NSS_HEADER;
void str_echo(int sockfd)
{
ssize_t readLen;
ssize_t writeLen;
char buf[8];
while ( true )
{
readLen = read(sockfd, buf, 8);
if (readLen < 0 && errno == EINTR)
{
continue;
}
else if ( readLen <= 0 )
{
perror( "read:");
return ;
}
printf( "recv data successed. data len: %d\n", readLen );
int nWriteLen = 0;
while ( true )
{
writeLen == write(sockfd, &buf[nWriteLen], readLen-nWriteLen);
if (writeLen < 0 && errno == EINTR)
{
continue;
}
else if ( writeLen < 0 )
{
perror ( "write:" );
return;
}
nWriteLen += writeLen;
// ÒÑдÍֱ꣬½Ó·µ»Ø
if (nWriteLen >= readLen )
{
break;
}
}
printf( "send data successed. data len: %d\n", readLen );
}
}
int main(int argc, char **argv)
{
printf( "server ip: %s\n", argv[1] );
printf( "server port: %s\n", argv[2] );
printf( "\nservice starting ... \n\n" );
int listenfd, connfd;
pid_t childpid;
socklen_t clilen;
struct sockadd


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌá¹©ÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

ʵսLinux Bluetooth±à³Ì(Áù) L2CAP±à³ÌʵÀý

ÀýÒ»£º·¢ËÍ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 ......

8¸ö×îºÃµÄLinuxƽ̨ÉÌÒµÖÇÄÜ£¨BI£©Èí¼þ

ÉÌÒµÖÇÄܹ¤¾ßÊÇ´Ó²»Í¬ÀàÐ͵ÄÊý¾ÝÔ´ÖÐÍÚ¾òÊý¾Ý£¬ÓÃÀ´Éè¼ÆºÍ²úÉú±¨±í¡£ÉÌÒµÖÇÄÜÈí¼þÀàÐÍÒ²ºÜ¶à£¬°üÀ¨±¨±íºÍ²éѯÈí¼þ£¬Êý×ÖÒDZíÅÌ£¬´¦ÀíºÍÊý¾ÝÍÚ¾ò£¬¾­Óª¼¨Ð§
¹ÜÀíÒÔ¼°µç×ÓÊý¾Ý±íµÈ¡£Ò»°ãÒ»¸öÉÌÒµÖÇÄÜÆ½Ì¨°üÀ¨Èý¸ö²ãÃæ£ºÊý¾Ý²ã£¬ÉÌÒµÖÇÄܲ㣬·ÖÎö/¼¨Ð§¹ÜÀí²ã¡£±¾ÎĽ«½éÉÜ8¸ö×îºÃµÄLinuxƽ̨ÏÂÉÌÒµÖÇÄÜÈí¼þ£º
Pentaho£ºÌṩÆó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ