首页 > 编程语言 >CSE-111 socket编程

CSE-111 socket编程

时间:2023-06-08 11:57:34浏览次数:37  
标签:socket CSE messages robot server state client 111 using


Coursework assignment
“Stateful robot using protobuf and sockets”
CSE-111 Week 7
Background
We have now progressed to writing simple client-server C++ applications “from scratch”.
This assignment gives you a taste of what’s required to write an application which has functionality in
both a client and in a server and uses serialized messages to communicate across a TCP socket
connection.
It’s a pattern for larger applications like multiplayer games.
I’ve previously given you recipes/examples for:
• A client-server application (two versions – one using select(), one without)
• Message serialization using protocol buffers (protobuf_example)
• Generating “ticks” using a combination of sleep() and the C++ millisecond capable clock
(described in class on Wednesday 5/17/23)
• Implementing a state machine to describe the behavior of a simple robot that alternates
between waiting and moving (separate states – described in class on Wednesday 5/17/23) and
based on the reception of messages.
I’ve included two skeleton makefile based projects “robot_client” and “robot_server” in a single
“state_robot.zip” file.
These are skeleton projects with just an appropriate makefile options and main() method inside a top
level directory called “state_robot”.
The deliverable
Modify/Implement code for these skeleton projects so that robot_client can connect over TCP to the
robot_server using sockets.
You do not need to support multiple clients connected to a single server. One is fine.
A forever while loop in robot_client should sleep for a short period of time (say 500 milliseconds) and
send a serialized “tick” message to the robot_server.
The tick message should be a protobuf message, and I’ve given you a Message.proto file (in both
projects) which describes the format of the message.
On the robot server, receive the messages, deserialize them and implement a simple state machine to
make the robot alternate between sleeping and moving states; for each tick message received on the
server, output one of the strings defined in the robot_server Main.cpp file depending on what state the
robot it in.
If the operation of the client is interrupted, clean up the connection on the server appropriately, so that
the client can reconnect again.
To state the obvious, when the client is disconnected, the server should not be outputting messages, as
it doesn’t receive the tick messages from the client.
Please be sure to include the exact text from the robot messages to journal out the robot state to
std::cout. This will be used for grading; you can add stuff, but be sure these messages are included in the
output.
When you have completed the work, zip up the entire state_robot top-level directory and return this as
a submission for the coursework assignment using canvas.
Successful submission criteria
You’ll need to submit back the modified robot_client and robot_server projects (I.E. submit a zip of the
toplevel state_robot directory).
Both these projects should
a) Compile without warnings or errors
b) Work, in that they connect to each other, with the connection initiated by the client
c) Work, in that the client periodically sends messages to the server, causing the robot to change
state (with a reasonable frequency, say once a minute or ½ minute)
d) Work in that, once the client is interrupted and disconnects, you can connect it again to the
server by running the client once more.
e) Produce appropriate messages from server to std::cout indicating the state of the robot
f) Use the strings from the projects as output indicating state changes, so that we can evaluate
your submission.

 

标签:socket,CSE,messages,robot,server,state,client,111,using
From: https://www.cnblogs.com/simpleyfc/p/17465777.html

相关文章

  • Elasticsearch专题精讲—— REST APIs —— Document APIs —— Reindex API
    RESTAPIs——DocumentAPIs——ReindexAPIhttps://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-reindex.html#docs-reindexCopiesdocumentsfromasourcetoadestination.将文档从源复制到目标。Thesourcecanbeanyexist......
  • 1112.开发模式场景以及Git
    一、开发模式与场景1.客户端和服务端①什么是服务端理解服务端之前先搞清楚什么是服务器?服务器就是提供网络服务的机器设备!1.高效提供网络服务;2.多用户与用户组以及权限的管理;3.全年24小时不间断运行,无需关机重启。那服务端是什么了?就是运行在服务器上面提供具体网络......
  • ElasticSearch-API-Index的使用亲测
    ElasticSearch-API-Index索引创建API允许初始化一个索引。ElasticSearch对多重索引提供了支持,包括跨多个索引执行操作。每个索引在创建时可以让一个特定的设置项与其关联。最简单的方式创建索引curl-XPUT‘http://localhost:9200/twitter/'在创建索引的时候指定分片和副本数量,参......
  • 一文搞懂TCP、HTTP、Socket、Socket连接池
    一文搞懂TCP、HTTP、Socket、Socket连接池架构师社区 2023-06-0711:40 发表于北京作者:数澜科技来源:www.jianshu.com/p/e47a766e03da前言:作为一名开发人员我们经常会听到HTTP协议、TCP/IP协议、UDP协议、Socket、Socket长连接、Socket连接池等字眼,然而它们之间的关系......
  • 一文搞懂TCP、HTTP、Socket、Socket连接池
    前言:作为一名开发人员我们经常会听到HTTP协议、TCP/IP协议、UDP协议、Socket、Socket长连接、Socket连接池等字眼,然而它们之间的关系、区别及原理并不是所有人都能理解清楚,这篇文章就从网络协议基础开始到Socket连接池,一步一步解释他们之间的关系。七层网络模型首先从网络通信的......
  • ElasticSearch
    端口9300组件间通信,9200http界面端口,5601kibana界面基本操作es不支持修改索引信息###创建索引shopping,es中的索引类似于关系数据库中的库curl-XPUThttp://localhost:9200/shopping###查看索引curl-XGEThttp://localhost:9200/shopping###查看所有索引curl......
  • elasticsearch查询
    elasticsearch查询,elasticsearch常见查询,elasticsearch命令elasticsearch常用命令1、查询索引GET_cat/indices 2、查看es磁盘使用情况GET_cat/allocation?v&pretty 3、查看es分词情况GET_analyze{"text":"中国"}elasticsearch常用查询查询基本语法,所......
  • PS3111固件找到了,贴一个Phison自封颗粒的PS3111 512GB的硬盘
    硬盘是我在某鱼花了70块钱包邮淘的坏盘,颗粒封装是群联自封的,看ID却是凯侠的BICS3(纯正群联自封TSBBiCS3,T开头是东芝,C开头才是长江)盘是神舟笔记本上面的坏盘,主控是PS5008,短命的主控,协议速度是pcie3.0x2。拆下颗粒,植球,找一个mSATA的PS3111空板,全部焊接上去。完成品,准备开卡。先清空fl......
  • nginx代理webSocket 和eventSource 相关配置
    文章转载自: https://blog.csdn.net/Embrace924/article/details/92649471nginx代理webSocket和eventSource请求超时连接不通但是本地可以nginx代理出了问题不能普通代理一样要先发起普通请求代理然后通过一些属性再次转换#常用配置location/api/{    proxy_pas......
  • 【汽车处理器】TMS5701115CPGEQQ1 Hercules™ TMS570 ARM® Cortex®-R
    TMS5701115CPGEQQ116/32位RISC闪存微控制器(MCU)是一个用于安全系统的高性能汽车级微控制器系列。其采用的安全架构包括锁步中的双CPU、CPU和内存内置自检(BIST)逻辑、闪存和数据SRAM上的ECC、外设存储器上的奇偶校验以及外设I/O上的回路功能。TMS570器件集成了可提供高效1.66......