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

linux socket±à³Ì»ùÓÚ±¾µØunixÓò¸ñʽµÄЭÒé×å

Í·Îļþ£º
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/select.h>
·þÎñÆ÷¶Ë´úÂ룺
int main(int argc, char **argv)
{
  struct sockaddr_un address;
  int sock, conn;
  int addrLength;
  char buf[1024] = {0};
  char *msg = "I has recived";
  if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
  {
    perror("socket");
    exit(0);
  }
  unlink("foo.sock");
  address.sun_family = AF_UNIX;
  strcpy(address.sun_path, "foo.sock");
  addrLength = sizeof(address.sun_family) + strlen(address.sun_path);
  if(bind(sock, (struct sockaddr *) &address, addrLength))
    perror("bind");
  if(listen(sock, 5))
    perror("listen");
  while((conn = accept(sock, (struct sockaddr *) &address, &addrLength)) >= 0)
  {
    recv(conn, buf, sizeof(buf), 0);
    printf("%s\n", buf);
    send(conn, msg, strlen(msg), 0);
  }
  return 0;
}
¿Í»§¶Ë´úÂ룺
int main(int argc, char **argv)
{
  int client_fd;
  int len;
  ssize_t  I;
  char *msg = "hello server";
  char buf[1024] = {0};
  struct sockaddr_un remote;
  if((client_fd = socket(AF_LOCAL, SOCK_STREAM, 0)) == -1)
  {
    perror("socket()");
    exit(0);
  }
  remote.sun_family = AF_LOCAL;
  strcpy(remote.sun_path, SOCK_PATH);
  len = sizeof(remote);
  //puts("hello, hello, hello, hello");
  if(connect(client_fd, (struct sockaddr *)&remote,


Ïà¹ØÎĵµ£º

Linux LDDÃüÁîµÄʹÓÃ

1.Ê×ÏÈldd²»ÊÇÒ»¸ö¿ÉÖ´ÐгÌÐò£¬¶øÖ»ÊÇÒ»¸öshell½Å±¾
 
2¡¢lddÄܹ»ÏÔʾ¿ÉÖ´ÐÐÄ£¿éµÄdependency£¬ÆäÔ­ÀíÊÇͨ¹ýÉèÖÃһϵÁеĻ·¾³±äÁ¿£¬ÈçÏ£ºLD_TRACE_LOADED_OBJECTS¡¢LD_WARN¡¢LD_BIND_NOW¡¢LD_LIBRARY_VERSION¡¢
LD_VERBOSEµÈ¡£µ±LD_TRACE_LOADED_OBJECTS»·¾³±äÁ¿²»Îª¿Õʱ£¬ÈκοÉÖ´ÐгÌÐòÔÚÔËÐÐʱ£¬Ëü¶¼»áÖ»ÏÔʾģ ......

Linux Cº¯Êý¿â²Î¿¼ÊÖ²á(Ò»)

µÚ1ÕÂ×Ö·û²âÊÔº¯Êýisalnum(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ»òÊý×Ö)isalpha(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ)isascii(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂë×Ö·û)isblank(²âÊÔ×Ö·ûÊÇ·ñΪ¿Õ¸ñ×Ö·û)iscntrl(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂëµÄ¿ØÖÆ×Ö·û)isdigit(²âÊÔ×Ö·ûÊÇ·ñΪ°¢À­²®Êý×Ö)isgraph(²âÊÔ×Ö·ûÊÇ·ñΪ¿É´òÓ¡×Ö·û)islower(²âÊÔ×Ö·ûÊÇ·ñΪСдӢÎÄ×Öĸ)isprint(² ......

LINUXÍø¿¨°ó¶¨¾ÛºÏÉèÖÃ

LINUXÍø¿¨°ó¶¨¾ÛºÏÉèÖÃ
1.½¨Á¢ÐéÄâÍøÂç½Ó¿ÚÅäÖÃÎļþ£ºifcfg-bond0
cd /etc/sysconfig/ network-scripts/
[root@rhas-13 root]# vi ifcfg-bond0      (½¨Á¢ifcfg-bond0Îļþ)

2.±à¼­ÐéÄâÍøÂç½Ó¿ÚÅäÖÃÎļþ
#vi ifcfg-bond0  
½«µÚÒ»ÐÐ¸Ä³É DEVICE=bond0  
# cat ifcfg-bond ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ