package com.test.server; import java.io.IOException; import java.net.ServerSocket; import org.apache.log4j.Logger; public class Server{ private static final Logger logger = Logger.getLogger(Server.class); public static ServerSocket server = null; sta
client and server Demo of socket. client send data to server. server send data to client. // this is client #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <assert.h> #include <stdio.h> #incl
socket client 发起连接. 流程为: 创建接口 发起连接 创建接口参数同socket server相同 发起连接的函数为socket.connect(ip,port) 这个地方的ip与port为socket server端的ip和监听port. 代码示例: # -*- coding: utf-8 -*- ''' This is a testing program the program is used to test socket client ''' import socket i
<Beginning Linux Programming_4th> chapter 15 Sockets 1 A simple local client/server 1) client.c // 1) header files // int socket(int domain, int type, int protocol); #include <sys/types.h> // int connect(int socket, const struct sockaddr*ad