/* ============================================================================ Name : TestServer.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <linux/in.h> #include <string.h> int main(void) { int sfp, nfp; int sin_size; struct sockaddr_in s_add, c_add; int port = 8888; sfp = socket(AF_INET, SOCK_STREAM, 0); if (sfp == -1) { printf("socket build fail\r\n"); return -1; } printf("socket ok!\r\n"); bzero(&s_add, sizeof(struct sockaddr_in)); s_add.sin_family = AF_INET; s_add.sin_addr.s_addr = htonl(INADDR_ANY); s_add.sin_port = htons(port); if (-1 == bind(sfp, (struct sockaddr *) (&s_add), sizeof(struct sockaddr))) { printf("bind error\r\n"); return -1; } printf("bind ok\r\n"); if (-1 == listen(sfp, 5)) { printf("listen fail ! \r\n"); return -1; } while (1) { sin_size = sizeof(struct sockaddr_in); nfp = accept(sfp, (struct sockaddr *) (&c_add), &sin_size); if (-1 == nfp) { printf("accept error \r\n"); return -1; } printf("accept ok \r\n"); write(nfp,"hello,welcome to my server \r\n", 32); } return EXIT_SUCCESS; }
相关推荐
By the end of this book, you’ll have experience of working with client-server applications, and be able to implement new network programs in C. The code in this book is compatible with the older C99 ...
IRC-chatSystem IRC简单聊天系统 IRC simple chat system linux大型实验 ...源代码一份 client.c server.c (含user.ini) 技术说明文档一份 IRC软件技术报告.pdf 使用说明文档一份 IRC软件使用说明书.pd
This document contains the solutions to review questions and problems for the 5th edition of Computer Networking: A Top-Down Approach by Jim Kurose and Keith Ross. These solutions are being made ...
* Mini Binl Server * Copyright (c) 2005-2007 Gianluigi Tiesi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * ...
More jobs can be done by implementing the client ;; utilities. It is listening on `[Listen_Port]/Data' port. ;; ;;------------------------------------------------------------------------------ ;; Tip...
An additional chapter on socket programming in C++ (contributed by David B. Sturgill). The PracticalSocket library provides wrappers for basic socket functionality. These allow an instructor to ...
Protocol Usage by Common Internet Applications Section 2.14. Summary Exercises Part 2: Elementary Sockets Chapter 3. Sockets Introduction Section 3.1. Introduction Section 3.2. Socket...
3、Can’t connect to local MySQL server through socket ‘/Data/mydata/mysql.sock’ socket文件目录不对应导致的问题 4、今天要说的就是 没有打开only_full_group_by Cause:...
socket连接,使用ssl建立安全通道...Makefile: used to generate app_client and app_server by client.c and server.c client.c:the client use ssl to transfer data server.c: the server use ssl to transfer data
基于我们开源的Modbus协议栈实现的Modbus TCP客户端和服务器示例,使用VS2019开发。
this server and client programs is created for the s3c2410 platform board to conveniencely control it and fulfil files transferring at the same time , that is a simple combination for telnet and ...
this server and client programs is created for the s3c2410 platform board to conveniencely control it and fulfil files transferring at the same time , that is a simple combination for telnet and ...
The book will then focus on writing extendable RxPHP code by developing a code testing tool and also cover Using RxPHP on both the server and client side of the application. With a concluding chapter...
Changes in 2.4.6 (February 22, 2011): Brief summary : - Support more host OS to run on: - Include win64 native binary in the ... [2914433] makesym.perl misses symbols by John R. Jackson [2908481] USB ...
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org) # The author disclaims copyright to this source code. import sys import struct import socket import time ...
.\Samples\delphi\SocketDemos Delphi Win32/Win64 Socket sample applications (all Delphi versions) .\Samples\delphi\sslinternet Delphi Win32/Win64 SSL-enabled sample applications (all Delphi versions) ....
Usage example: 1. Build or install ...2. Switch to /server folder and build server by maven. 3. Run server by command `mvn exec:java` 4. Run client in browser, by opening* file /client/index.html
/* 本程序用Visual C++ 6.0编译在Windows 2000 Advanced Server 上调试通过 */ /* Created by janker@371.net 2000.8.28 */ /* 声明:本程序经修改后可能会产生攻击性擅自修改成攻击程序者后果...