一个简单的客户端服务端程序

Qtradex图形界面版本可设定交易参数 实现上期技术的行情和交易接口,通过qt mvc 编程模型,实现前后台分离,前台获取用户输入参数,中间层辅助数据传输业务处理,后台专注行情数据分析,交易决策。参数设定后,界面自动退出,后台继续运行算法进行交易。 C++QT 立即下载

客户端
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 100
int main()
{
  int sockfd,len;
  struct sockaddr_in address;  
  int result;
  FILE*fd= fopen(“sunrise.jpg”,“wb”);
  char recvs[MAXSIZE];
  sockfd=socket(AF_INET,SOCK_STREAM,0);
  address.sin_family=AF_INET;
  address.sin_addr.s_addr=inet_addr(“127.0.0.1”);
  address.sin_port=9734;
  len=sizeof(address);
  result=connect(sockfd,(struct sockaddr *)&address,len);
  if(result==-1){
  perror(“oops:client1”);
  exit(1);
  }
  int count;
  while(1){
  int count;
  count=read(sockfd,recvs,MAXSIZE);
  if(count==0)
  break;
  fwrite(recvs,1,MAXSIZE,fd);
}
close(sockfd);
fclose(fd);
return 0;
}

服务器
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define MAXSIZE 100
int main()
{
  FILE *fd=fopen(“Sunset.jpg”,“rb”);
  int server_sockfd,client_sockfd;
  int server_len,client_len;
  struct sockaddr_in server_address;
  struct sockaddr_in client_address;
  server_sockfd=socket(AF_INET,SOCK_STREAM,0);
  server_address.sin_family=AF_INET;
  server_address.sin_addr.s_addr=inet_addr(“127.0.0.1”);
  server_address.sin_port=9734;
  server_len=sizeof(server_address);
  bind(server_sockfd,(struct sockaddr *)&server_address,server_len);
  listen(server_sockfd,5);
  char ch[MAXSIZE];
  client_len=sizeof(client_address);
  client_sockfd=accept(server_sockfd,(struct sockaddr *)&client_address,&client_len);
  while(!feof(fd)){
  fread(ch,1,MAXSIZE,fd);
  write(client_sockfd,ch,MAXSIZE);
}
  close(client_sockfd);
  fclose(fd);
  return 0;
}

/**
 * @file a.c
 * @brief
 * @author miracle, miracle.taox@gmail.com
 * @version 1.0
 * @date 2016-10-12
 */
#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
#include<string.h>
#include<netdb.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include<unistd.h>
#include<pthread.h>

#define MAXSIZE    1024

void setHostIP();
int sendApp1();
int sendApp2();
int sendApp3();
#if 1
int main()
{
    pthread_t p_camera;
    pthread_attr_t attr_camera;
    pthread_attr_init(&attr_camera);
    pthread_attr_setdetachstate(&attr_camera,PTHREAD_CREATE_DETACHED);
    //setHostIP();
    if(pthread_create(&p_camera,&attr_camera,(void *)sendApp3,NULL) != 0)
    {
        printf(“Net creat pthread err.”);
        exit(1);
    }

while(1)
    {
        sleep(1);
    }
    printf(“main is over\n”);
}
#endif
void setHostIP()
{
    char tbuf[128];

system("/sbin/ifconfig eth0 down > /dev/null");
    system("/sbin/ifconfig ra0 down > /dev/null");
    //sprintf(tbuf,"/sbin/ifconfig eth1 hw ether 1234567890%d > /dev/null",bedno);//linzilin–下面这2个要同时搞
    //system(tbuf);

system("/sbin/ifconfig ra0 up > /dev/null");
    system(“killall wpa_supplicant &”);
    system("/usr/sbin/wpa_supplicant -B -ira0 -c /etc/wpa_supplicant.conf -Dwext &");
    //system(“iwlist eth1 scanning”);
    sprintf(tbuf, “/sbin/ifconfig ra0 202.114.4.200 > /dev/null”);//linzilin–这2个要同时搞 
    //sprintf(tbuf, “/sbin/ifconfig ra0 202.114.4.115 > /dev/null”);//linzilin–这2个要同时搞 
    system(tbuf);
}

int sendApp3()
{
    int sockfd,new_fd;
 int nbytes;
    struct sockaddr_in server_addr;/定义服务器端套接口数据结构 server_addr/
    struct sockaddr_in client_addr;/定义客户端套接口数据结构 client_addr/
    int sin_size,portnumber;
    char buf[MAXSIZE];
   static char ServerIP[20]=“192.168.1.43” ;
printf(“00*************************************\n”);
    /服务器端开始建立socket描述符/
    if((sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1)
    {
        fprintf(stderr,“Socket error:%s\n\a”,strerror(errno));
        exit(1);
    }
    /服务器端填充sockaddr结构/
    bzero(&server_addr,sizeof(struct sockaddr_in));//先将套接口地址数据结构清零
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = inet_addr((char ) ServerIP);;
    //server_addr.sin_port = htons(portnumber);
    server_addr.sin_port = htons(9999);
printf("11
INADDR_ANY = %s\n",INADDR_ANY);
    /调用bind函数绑定端口/
    if(bind(sockfd,(struct sockaddr )(&server_addr),sizeof(struct sockaddr)) == -1)
    {
        fprintf(stderr,“Bind error:%s\n\a”,strerror(errno));
        exit(1);
    }
    /端口绑定成功,监听sockfd描述符,同时处理的最大连接请求数为5/
    if(listen(sockfd,5) == -1)
    {
        fprintf(stderr,“Listen error:%s\n\a”,strerror(errno));
        exit(1);
    }
printf("22
\n");
    /服务器阻塞,等待接收连接请求,直到客户程序发送连接请求/
    while(1)
    {
        sin_size = sizeof(struct sockaddr_in);
printf(“88888*************************************\n”);
        /调用accept 接受一个连接请求/
        if((new_fd = accept(sockfd,(struct sockaddr )(&client_addr),&sin_size)) == -1)
        {
            fprintf(stderr,“Accept error:%s\n\a”,strerror(errno));
            exit(1);
        }
printf("23333
************************************\n");

/TCP 连接已建立,打印申请连接的客户机的IP地址/
        fprintf(stderr,“Server get connection from %s\n”,inet_ntoa(client_addr.sin_addr));
        /提示用户输入将要发送的数据,长度小于缓冲区的长度,即1024字节/
        printf(“Connected successful,please input the message[<1024 bytes]:\n”);

#if 1
while(1)
{
   if((nbytes = recv(new_fd, buf, MAXSIZE, 0)) < 0)
    {
        fprintf(stderr,“4Gethostname error\n”);
        exit(1);
    }
    //buffer[nbytes] = ‘\0’;
    printf(“I have received:%s\n”,buf);
    printf(“nbytes = %d\n”,nbytes);
if(nbytes == 25)
{
 int i = 0;
 for(i = 0; i < 53;i++)
{
 sprintf(“buf[%d] = %x\n”,i, buf[i]);
}
}
    memset(buf,0,sizeof(buf));  
}
 
#endif

}
    close(sockfd);//服务器进程结束,关闭服务器端套接口
    exit(0);
}

int my_system(const char * cmd_line)
{
 FILE *fp;
 int res = 0;
 char buf[1024];
 if(NULL == cmd_line)
 { 
  printf(“my_system cmd_line is NULL!\n”);
  return -1;
 }

if(NULL == (fp = popen(cmd_line, “r”)))
 {
  perror(“popen”);
  printf(“popen erro:%s\n”, strerror(errno));
  return -1;
 }
 else
 {
  while(fgets(buf, sizeof(buf), fp))
  {
   printf("%s", buf);
  }
  
  if(res = pclose(fp) == -1)
  {
   printf(“close popen file pointer fp error!\n”);
   return res;
  }
  else if(0 == res)
  {
   return res;
  }
  else
  {
   printf(“poen res is :%d\n”, res);
   return res;
  }
 }
}


作者:m0_37074021
来源:CSDN
原文:https://blog.csdn.net/m0_37074021/article/details/79036299
版权声明:本文为博主原创文章,转载请附上博文链接!

一个简单的服务端程序 简单的一个使用java servlet写的服务端程序 立即下载

相关推荐

TCP/IP客户端和服务器

最基本的网络编程 也是最重要的网络编程

【手把手教你写服务器】客户端程序和服务器程序的简单实现

1.基本TCP客户/服务器程序的套接字函数 2.server.c 3.client.c

脚踏实地,仰望星空 1539

程序化期货自动交易系统模拟版

1、在上海期货信息技术仿真交易网站(http://www.simnow.com.cn/static/register1.action)上注册仿真交易账户。 2、在账号注册后的第三个交易日修改注册密码后,打开软件,输入仿真交易账户和密码。 3、程序能自动化交易期货合约,并生成交易日志。 如果出现找不到msvcp140.dll的情况,请安装vs2015运行库。

简单的服务端和客户端通信的一个程序

先写服务端,再写客户端,然后运行服务端,再运行客户端 #include&lt;WinSock2.h&gt; //socket:API 2.2 #include&lt;stdio.h&gt; #pragma comment(lib,"ws2_32.lib")//加载静态库,提供对网络相关API的支持 /* *套接字: *IP、端口号 ,套接字绑定, */ int main() { //加载...

qq_22080999的博客 1773

期货策略自动交易软件模拟版

1、在上海期货信息技术仿真交易网站(http://www.simnow.com.cn/static/register1.action)上注册仿真交易账户。 2、在账号注册后的第三个交易日修改注册密码后,打开软件,输入仿真交易账户和密码。 3、程序能自动化交易期货合约,并生成交易日志。 如果出现找不到msvcp140.dll的情况,请安装vs2015运行库。

bcftools实战指南:从VCF文件处理到变异分析全流程解析

在基因组数据分析中,VCF(Variant Call Format)文件是存储基因序列变异信息的标准格式,广泛应用于群体遗传学和生物信息学研究。其核心原理是通过结构化文本记录SNP、INDEL等变异位点的基因型、质量值和注释信息。掌握高效处理VCF文件的技术,对于提升变异检测、数据清洗和下游分析的工作流效率具有重要价值。在生物信息学工具生态中,bcftools作为处理VCF/BCF文件的瑞士军刀,通过模块化设计实现了数据查询、过滤、统计和格式转换等核心功能。其流式处理架构支持管道化操作,能有效应对海量基因组

weixin_29081703的博客 328

建立简单的服务器端程序

参考自core java package com.lujinhong.corejava; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.net.ServerS...

apple01010105的博客 152

帕塞瓦尔定理(Parseval‘s theorem)的证明

帕塞瓦尔定理(Parseval's theorem)表明了信号在时域和频域上的能量相等。

weixin_42428226的博客 2万+

网络编程-一个简单的客户端与服务器程序(0),(看这篇就够了)

写客户端与服务器程序之前,相信都对TCP的三次握手,四次挥手有一定的了解。如果还不了解的朋友可以看这两篇网络编程-从TCP三次握手说起和网络编程-TCP的四次挥手 服务器和客户端程序的流程 基于TCP/IP协议的服务器和客户端程序的一般流程,如下图所示: 1、服务器初始化一一LISTEN (1)调用socket函数创建文件描述符。 (2)调用bind函数将当前的文件描述符和ip/port绑定在一...

chen1415886044的博客 7356

ABAP OO - ALV_TREE例程

项目上比较少有用到ALV_TREE的报表功能,刚好项目上有写了一次,也查阅大量的范例,整合了一写法,给自己做一下笔记。 程序包含功能按钮,按钮下拉,F4帮助,读取选中行,字段双击触发事件,字段前置图标,更新节点,获取节点数据,获取全部子节点,递归算法,DMS模块:创建文档功能,创建文档链接,SNRO创建流水号,缓存数据,下次用户加载进来继续操作。 *&---------------------------------------------------------------------* *&a

大步甩起来 4998

解锁Jetbrains AI助手:中国开发者实战配置与效率跃迁指南

本文为中国开发者提供了一份详细的Jetbrains AI助手实战配置指南。针对服务地域限制,核心解决方案是通过修改Jetbrains账户区域信息并配置网络代理,实现插件的稳定启用。文章进一步分享了AI助手在解读遗留代码、生成中文提交信息、智能问答等场景下的具体应用,旨在帮助开发者深度集成这一工具,实现编码生产力的显著提升。

weixin_28832121的博客 585

01 TCP Socket 编程_一个简单的服务端程序和客户端程序实现

流套接字TCP / IPSOCK_STREAM服务端程序Socket —  bind — listen — accept  send/recv — close客户端程序Socket — connect — send/recv — close #pragma comment(lib,"ws2_32.lib") #include #include #include int mai

蝴蝶梦 733

OpenClaw小白安装全攻略:5000字详解,3分钟上手

为什么值得装 OpenClaw?最近科技圈爆火的 OpenClaw(昵称 “小龙虾”),不是普通 AI 聊天工具 —— 它是能本地部署、直接操控电脑的 AI 智能体,相当于给电脑配了个 “全能助手”:整理文件、自动搜资料、写文档、控制浏览器,甚至对接微信 / 飞书发消息,全程不用手动操作。更关键的是:它免费开源、支持全平台,新手不用懂代码,复制粘贴命令就能装,数据存在本地不泄露隐私。截至 2026 年 3 月,GitHub 星标已破 25 万,券商都出研报推荐,上班族、学生党用它提升效率超香!

通俗易懂学IT 1214

编写一个最简单的Linux服务端和客户端程序

2023年8月3日,周四下午。

m0_61629312的博客 603

抖音 webmssdk 签名算法解析:X-Dynosaur / X-Gnarly / X-Bogus 生成原理

它只依赖设备指纹/环境编码与随机数,与 query 内容无关,因此可以独立于 Dynosaur/Gnarly 生成。

猫敷雪 226

vue3中使用antv-S2表格(基础功能版)

表格的数值默认会渲染排序 icon, 可以配置 showDefaultHeaderActionIcon关闭。当配置为对象时,always 控制是否在子维度不足 2 个时始终展示小计,默认不展示。首先创建一个vue3+vite+ts项目,可以查看下面相关文章,只看第一条即可。可以调整行宽、列宽、列排序、单个单元格详情展示、选中某列、某行等基本功能。可以通过上面设置的SUM函数自动计算出数值,也可以自定义累加函数。配置自定义方法优先级大于配置聚合方式,即配置。1、在项目中安装(npm/pnpm都可以)

蜗牛~~ 2212

linux下一个简单的TCP通信程序——客户端向服务端发送任意字符串

程序目的:服务器端等待客户端连接,若连接成功,则用户可以通过服务器在接受到字符串后进行判断,若不是quit字符串则输出客服端的地址信息,以及接受到的数据,同时将接受到的数据按照原样再发给客服端,若是quit字符串则断开本次连接。 问题以及解决:1)服务器端不能连续显示客户端发送的数据2)服务器端发送的数据在客户端正常显示一次,以后乱码。 #include #include #inc

haida_liudan的专栏 9677

基于多传感器融合的智身四足机器狗楼梯环境SLAM系统设计与实现

本文设计了一种基于多传感器融合的四足机器狗楼梯环境SLAM系统。系统采用Jetson Orin NX为主控制器,集成RealSense D435i深度相机和Livox Mid360激光雷达,在ROS2框架下实现平面定位精度<5cm、楼梯环境下导航不漂移的目标。通过多层次传感器融合策略、运动学约束优化和状态切换机制,解决了楼梯环境下的定位累积误差问题,实现了平面与楼梯环境的自动识别切换及精度复位功能。硬件设计注重传感器布局优化和精确标定,软件架构采用分层设计,确保实时性能。该系统为四足机器人在复杂地形中

huanghm88的专栏 254

编写一个最简单的Windows服务端和客户端程序

2023年8月4日,周五上午。

m0_61629312的博客 332

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

一个简单的TCP客户端、服务端会话程序(C#)

服务端:1. new 一个TcpListener listner2.listner.start3.while(true)4. 获取socket :Socket s = listner.AcceptSocket();5. 获取netstream:NetworkStream ns = new NetworkStream(s);6.读取netstream: StreamReader sr = new S

xxpyeippx的专栏 1948

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

基于CXF的一个简单的服务端与客户端程序

需要导入cxf需要的jar文件   首先需要有一个接口:   import java.util.List;   import javax.jws.WebParam; import javax.jws.WebService; @WebService public interface HelloWord { String sayHi(@WebParam(name="text")...

sungang1120的专栏 239

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

(原)一个简单的UDP服务端和客户端程序

刚学linux socket。写来一个UDP发送和接受数据包的程序. client_main.c: /* * @file client_main.c * @brief client of the UDP. * @author xiaou */ #include <netinet/in.h> // for sockaddr_in #includ...

weixin_30606669的博客 100

一个TCP传输的客户端程序,服务端就不放了比较简单。

【代码】一个TCP传输的客户端程序,服务端就不放了比较简单。

m0_66804264的博客 465
上一篇: SQL将一个数据库中的数据复制到另一个数据库中
下一篇: 0xC0000005: 读取位置 0x00000000 时发生访问冲突
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值