tcp

Handling dropped TCP packets in C#

自古美人都是妖i 提交于 2021-02-03 05:59:45
问题 I'm sending a large amount of data in one go between a client and server written C#. It works fine when I run the client and server on my local machine but when I put the server on a remote computer on the internet it seems to drop data. I send 20000 strings using the socket.Send() method and receive them using a loop which does socket.Receive(). Each string is delimited by unique characters which I use to count the number received (this is the protocol if you like). The protocol is proven,

Handling dropped TCP packets in C#

╄→гoц情女王★ 提交于 2021-02-03 05:59:25
问题 I'm sending a large amount of data in one go between a client and server written C#. It works fine when I run the client and server on my local machine but when I put the server on a remote computer on the internet it seems to drop data. I send 20000 strings using the socket.Send() method and receive them using a loop which does socket.Receive(). Each string is delimited by unique characters which I use to count the number received (this is the protocol if you like). The protocol is proven,

Sending and receiving protobuf data over Socket via boost asio

大憨熊 提交于 2021-01-29 22:16:10
问题 I want to send Protobuf data from my server to my client thanks to a TCP socket. I tested my client and my server and the TCP connexion works. So I try to serialize my data and send it by using a streambuf. In my server : void SendData(protobufType data){ std::ostream ostream(&this->m_streambuf); data.SerializeToOstream(&ostream); std::cout<<"Send data"<< std::endl; boost::asio::write(this->m_socket, this->m_streambuf); } In my client : boost::asio::streambuf response; boost::asio::read

TCP fixed size message framing method in Golang

这一生的挚爱 提交于 2021-01-29 19:25:12
问题 I'm not able to understand how message framing using fixed size prefix length header works. It's said that a fixed size byte array is going to contain the length for message to be sent. But how would you define a fixed size byte array, specifically in Golang. Say this is my message: Hello Its length is 5. So if I want to send this through a tcp stream, to make sure I receive all the message on the other end I'd have to tell it how many bytes it should read. A simple header would be length

Go: efficiently handling fragmented data received via TCP

空扰寡人 提交于 2021-01-29 17:12:40
问题 I am writing a small tcp-server that is only suppose to read data, parse the receiving data (dynamic length frames) and handling these frames. Consider the following code: func ClientHandler(conn net.Conn) { buf := make([]byte, 4096) n, err := conn.Read(buf) if err != nil { fmt.Println("Error reading:", err.Error()) return } fmt.Println("received ", n, " bytes of data =", string(buf)) handleData(buf) This is pretty much the essence of my code as is. I read X bytes into a empty buffer and then

Binding a port for client tcp socket

蹲街弑〆低调 提交于 2021-01-29 15:44:56
问题 I have a problem about 'binging a local port for a client tcp socket'. The code is as below: void tcpv4_cli_connect(const char *srvhost, in_port_t srvport, const char *clihost, in_port_t cliport) { struct sockaddr_in srvaddr, cliaddr; struct in_addr inaddr; int sockfd; bzero(&srvaddr, sizeof(srvaddr)); inet_aton(srvhost, &inaddr); srvaddr.sin_family = AF_INET; srvaddr.sin_addr = inaddr; srvaddr.sin_port = htons(srvport); bzero(&cliaddr, sizeof(cliaddr)); inet_aton(clihost, &inaddr); cliaddr

Python TCP networking inconsistencies

大城市里の小女人 提交于 2021-01-29 13:46:26
问题 I'm new to networking and I'm trying to write a simple TCP client. The first thing I have to do is to send my message length and wait for further instructions. Here's my code: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.send(bytearray(message_serialised_length)) data = s.recv(BUFFER_SIZE) s.close() print("response: {}".format(struct.unpack('>I', data))) Sometimes, i'm able to get a response and the program continues but other times I run into this

Extract registers using Modbus RTU protocol

我怕爱的太早我们不能终老 提交于 2021-01-29 11:30:45
问题 I am new to using the Modbus protocol. I have a media converter device (USR-W610), I am testing the connection with the Modbus Poll and Modscan programsto verify that I am getting logs. I have these settings on the device. Using TCP protocol and port 502 According to these configurations, I configure the following fields in Modscan I configure the Device Id = 240 and select "03. HOLDING REGISTER" to read the data, but nevertheless I get the following messages "uninitialized" and later

What happens when a long TCP segment is sent?

旧街凉风 提交于 2021-01-29 11:08:21
问题 I uploaded a txt file to a server and captured the upload with Wireshark. The issue is that there is a segment that is extreamly long and right after that i get ack's from the server for lower sequences than i should. on line 865 my PC sends a segment with the length of 12240. I should get an ack that is bigger than 12240 and yet this is not the case. Wireshark capture image 回答1: Look at frame 862. The host 128.119.245.12 is advertising an MSS of 1360 bytes. So, the maximum size of TCP

python public ip with sockets (err:cannot assign requested addr)

折月煮酒 提交于 2021-01-29 10:40:31
问题 After allowing my raspberry pi to access port 9999 of my router socketname.bind(96.231.140.202,9999) in python gives me a cannot assign error To port forward I used: myfiosgateway.com/#/firewall/portforward (the same method worked fo my apache server) and I have verified that 96.231.140.202 is my pub ip 回答1: You cannot bind to your public IP. Your router is doing that. You instead want to bind to your private IP and port forward traffic destined to 9999 to your bound IP on your pi, this