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

ÀûÓÃsocket±àдwindowsºÍlinuxͨѶ³ÌÐò

ÀûÓÃsocket±àдwindowsºÍlinuxͨѶ³ÌÐò
    socket±à³Ì´ó¼Ò¶¼ºÜÊìϤ£¬ÎÒÔÚÕâÀï¾Í²»ÔÙÂÞàÂÁË¡£Ö±½ÓÇÐÈëÕýÌâ¡£¸Ã³ÌÐò·ÖÁ½²¿·Ö£¬server¶ËºÍclient¶Ë£¨Ë­¶¼ÖªµÀ£©¡£ÆäÖÐserver¶Ë²ÉÓÃwindowsƽ̨£¬ÄÇlinuxƽ̨µ±È»ÊÇclient¶ËÁË¡£
ÕâÀïÊÇserver¶Ë³ÌÐò£º
/**********************************/
/* it worked as server under windows platform */
/* written by mlsx 1998-2-7                     */
/************************************/
include <windows.h>
#include <stdio.h>
#pragma comment (lib,"WS2_32.lib")
#define USERPORT 10001
#define HOST_IP_ADDR "127.0.0.1"
main(int argc,char *argv[])
{
char buf[128];
SOCKET s,ns;
struct sockaddr_in client;
struct sockaddr_in server;
int namelen,pklen;
int status;
WSADATA wsd;
if((status=WSAStartup(MAKEWORD(2,2),&wsd))!=0)
{
  perror("wsastartup() failed:");
   exit(1);
}
if((s=socket(AF_INET,SOCK_STREAM,0))< 0)
{
  perror("socket failed :");
  exit(1);
}
ZeroMemory(&server,sizeof(server));
server.sin_family=AF_INET;
server.sin_port=htons(USERPORT);
server.sin_addr.s_addr=htons(INADDR_ANY);
if(bind(s,(struct sockaddr *)&server,sizeof(server))<0)
{
  perror("bind() failed:");
  exit(2);
}
if(listen(s,4)!=0)
{
  perror("listen()failed :");
  exit(3);
}
while(1)
{
namelen=sizeof(client);
if((ns=accept(s,(struct sockaddr*)&client,&namelen))==-1)
{
  perror("accept()failed:");
  exit(4);
}
printf("accept successful");
for(;;)
{
  if((pklen=recv(ns,buf,128,0))<0)
  {
   perror("recv() failed:");
   exit(5);
  }
  else
   if(pklen==0)
   {
    printf("recv():return FAILED,connected is shut down");
    


Ïà¹ØÎĵµ£º

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

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

ÈçºÎÔÚUbuntu±àÒëLinuxÄÚºË


Ê×ÏÈÐèÒªÏÂÔØLinux kernel£¬ÔÚwww.kernel.orgÀïÃæÏÂÔØ¡£È»ºóÐèÒª°²×°kernel-package£¬fakeroot¡£ÕâÑù×¼±¸¹¤×÷¾ÍÍê³ÉÁË¡£
ÏÂÃ濪ʼÄں˵ÄÅäÖá£×îÖØÒªµÄÒ»µãÊÇÈ¥µôkenerl hackingÑ¡ÏÏÂÃæµÄ“±àÒëÄں˴øÓÐdebugÐÅÏ¢”Ñ¡Ï·ñÔò±àÒë³öÀ´µÄÄÚºËÎÞ±ÈÅÓ´ó
¡£È»ºó¸ù¾Ý¸öÈËÐèҪȥµôһЩÇý¶¯¡£²»¹ý±ØÐëÇå³þÖªµÀ×Ô¼ ......

linux sock_rawԭʼÌ×½Ó×Ö±à³Ì

sock_rawԭʼÌ×½Ó×Ö±à³Ì¿ÉÒÔ½ÓÊÕµ½±¾»úÍø¿¨ÉϵÄÊý¾ÝÖ¡»òÕßÊý¾Ý°ü,¶ÔÓë¼àÌýÍøÂçµÄÁ÷Á¿ºÍ·ÖÎöÊǺÜÓÐ×÷ÓõÄ.Ò»¹²¿ÉÒÔÓÐ3ÖÖ·½Ê½´´½¨ÕâÖÖsocket
 
1.socket(AF_INET, SOCK_RAW, IPPROTO_TCP|IPPROTO_UDP|IPPROTO_ICMP)·¢ËͽÓÊÕipÊý¾Ý°ü
2.socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP|ETH_P_ARP|ETH_P_ALL))·¢ËͽÓÊÕÒÔÌ« ......

Linux ϵͳĿ¼½éÉÜ

/lib/
— °üº¬Ðí¶à±» /bin/ ºÍ /sbin/  ÖеijÌÐòʹÓõĿâÎļþ¡£Ä¿Â¼ /usr/lib/ Öк¬Óиü¶àÓÃÓÚÓû§³ÌÐòµÄ¿âÎļþ¡£
/libĿ¼Ï·ÅÖõÄÊÇ/binºÍ/sbinĿ¼Ï³ÌÐòËùÐèµÄ¿âÎļþ¡£/libĿ¼ÏµÄÎļþµÄÃû³Æ×ñÑ­ÏÂÃæµÄ¸ñʽ£º
libc.so.*
ld*
½ö½ö±»/usrĿ¼ÏµijÌÐòËùʹÓõĹ²Ïí¿â²»±Ø·Åµ½/libĿ¼Ï¡£Ö»ÓÐ/binºÍ/sbin ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ