资源简介
源码支持PLC200/300/400与上位机进行通讯,采用S7协议
代码片段和文件信息
/*
Part of multithreaded network servers. The servers MAIN thread is started by
the main program. It starts in turn the ACCEPTER thread which accepts a
connection and passes the file descriptor to the MAIN thread. The server MAIN
thread starts a PORT SERVER thread to handle the connection. Thus the
PORT SERVER thread is NOT a child of ACCEPTER but a brother and SIGCHILD goes
to the server MAIN. If it would go to ACCEPTER which is blocked in the
accept() system call we would get “process interrupted in system call“ and
that‘s it. Maybe its different with pthread library..?
Part of Libnodave a free communication libray for Siemens S7 300/400.
(C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2001..2005.
LIBNDAVE is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 or (at your option)
any later version.
LIBNODAVE is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this; see the file COPYING. If not write to
the Free Software Foundation 675 Mass Ave Cambridge MA 02139 USA.
*/
typedef struct {
int fd;
int port;
} accepter_info;
void *accepter(void *arg)
{
int s;
int newfd pipefd;
socklen_t addrlen;
struct sockaddr_in addr;
int i;
int opt;
usleep(10000);
pipefd = ((accepter_info *) arg)->fd;
LOG2(ThisModule “Accepter : My pipe is:%d\n“ pipefd);
FLUSH;
s = socket(AF_INET SOCK_STREAM 0);
if (errno != 0) {
LOG2(ThisModule “Accepter : socket %s\n“ strerror(errno));
FLUSH;
}
LOG2(ThisModule “Accepter : port %d\n“
((accepter_info *) arg)->port);
addr.sin_family = AF_INET;
addr.sin_port =htons(((accepter_info *) arg)->port);
// (((((accepter_info *) arg)->port) & 0xff) << 8) |
// (((((accepter_info *) arg)->port) & 0xff00) >> 8);
// LOG2(ThisModule“Accepter : port %d\n“addr.sin_port);
inet_aton(“0.0.0.0“ &addr.sin_addr);
opt = 1;
i = setsockopt(s SOL_SOCKET SO_REUSEADDR &opt 4);
LOG2(ThisModule “Accepter : setsockopt %s\n“ strerror(errno));
addrlen = sizeof(addr);
bind(s (struct sockaddr *) & addr addrlen);
LOG2(ThisModule “Accepter : bind %s\n“ strerror(errno));
listen(s 1);
LOG2(ThisModule “Accepter : listen: %s\n“ strerror(errno));
while (1) {
addrlen = sizeof(addr);
LOG1(ThisModule “Accepter : before accept\n“);
newfd = (accept(s (struct sockaddr *) & addr &addrlen));
LOG2(ThisModule “Accepter: after accept. New fd:%d\n“ newfd);
FLUSH;
LOG3(ThisModule “Accepter: PID(%d) client:%s\n“ getpid()
inet_ntoa(addr.sin_addr));
FLUSH;
write(pipefd &newfd sizeof(newfd));
}
shutdown(s 2);
LO
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3127 2018-02-02 19:02 libnodave-0.8.5(初始稿)\accepter.c
文件 4935 2018-02-02 19:02 libnodave-0.8.5(初始稿)\benchmark.c
文件 411 2018-02-02 19:02 libnodave-0.8.5(初始稿)\buildall
文件 7226 2018-02-02 19:02 libnodave-0.8.5(初始稿)\ChangeLog
文件 50036 2018-02-02 19:02 libnodave-0.8.5(初始稿)\contributions\LotTrack-103.zip
文件 17445 2018-02-02 19:02 libnodave-0.8.5(初始稿)\contributions\PowerBasic\Dave.bas
文件 76288 2018-02-02 19:02 libnodave-0.8.5(初始稿)\contributions\PowerBasic\Dave.exe
文件 35834 2018-02-02 19:02 libnodave-0.8.5(初始稿)\contributions\PowerBasic\Dave.inc
文件 52 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Editor.ddp
文件 5747 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Editor.dfm
文件 5392 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Editor.pas
文件 52 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Main.ddp
文件 9126 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Main.dfm
文件 9756 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\Main.pas
文件 374 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\NoDaveDemo.cfg
文件 2117 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\NoDaveDemo.dof
文件 1402 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\NoDaveDemo.dpr
文件 766 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\NoDaveDemo.ico
文件 1680 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\NoDaveDemo.res
文件 2569 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\SZLView.dfm
文件 2879 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Delphi\SZLView.pas
文件 6625 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Editor.lfm
文件 6793 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Editor.lrs
文件 5526 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Editor.pas
文件 7809 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Main.lfm
文件 8357 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Main.lrs
文件 9352 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\Main.pas
文件 10542 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\NoDaveDemo.lpi
文件 323 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\Lazarus\NoDaveDemo.lpr
文件 606720 2018-02-02 19:02 libnodave-0.8.5(初始稿)\DelphiComponent\Demo\NoDaveDemo.exe
............此处省略325个文件信息
- 上一篇:高等电磁场理论--科大
- 下一篇:bootstrap-文件上传模板
相关资源
- qmc3转换mp3格式工具
- 超分辨率重建SRCNN(GUI界面)
- MIPS多周期流水线CPU设计
- Tightly-Coupled Monocular Visual-Inertial Fusi
- CC2541中文手册
- 每日卡路里开发文档.doc
- Wireless Indoor Localization
- Edge Computing From Hype to Reality
-
Tree-ba
sed Convolutional Neural Networks - 2018 cfa 2级 mock题目
- EtherCAT_Communication
- Reinforcement Learning: An Introduction,Rich
- 五级流水线MIPS指令集cpu设计,verilo
- 截图cropper
- stm32f4+w5500+tcpclient/server源码
- WindriverPCIE驱动
- 基于多任务卷积网络(MTCNN)和Cente
- visual studio code 快捷键速查表JPG中文版
- hdc1080.pdf
- LORA完成.rar
- CAD绘图员技能等级三级鉴定 要求电子
- Chrome最新版本 67.0.3396.99正式版本版本
- qqkongjianqzckjr.zip
- 基于深度学习的链路预测
- 数字电路课程CPU设计verilog完整代码
- 有关于PCIE总线和PCIE M.2的接口规范定
- ECU-TEST基本教程
- tc234说明书
- DLP6401投影仪PCB
- Mask R-CNN.pptx
评论
共有 条评论