tcp

sockets programming: sending and receiving different data to different clients in C

空扰寡人 提交于 2021-02-08 12:02:36
问题 I have written a basic client server code in c socket programming using the TCP/IP protocol but i cant figure out how to make it connect to different clients and send/receive different data to and from them as a function to the client (meaning if its the first client send him that data and if its that client send him the other data) and so on. This is the only results i have found were sending the same data to different clients. Current Server: #include <stdio.h> #include <stdlib.h> #include

Using public IP address in sockets

馋奶兔 提交于 2021-02-08 10:51:37
问题 I am new to socket programming. My sockets work with localhost or local ip. But why can't I create a socket server with my public ip? When I try to do this in python, it complains "cannot assign requested address". import socket s=socket.socket() host="address" port=5000 s.bind((host, port)) s.listen(5) while True: c, addr=s.accept() result=c.recv(1024) print(result.decode('utf-8')) c.send(""" test """.encode('utf-8')) c.close() My IP I got from this website:http://whatismyip.host/ 回答1: A

Using public IP address in sockets

大兔子大兔子 提交于 2021-02-08 10:48:29
问题 I am new to socket programming. My sockets work with localhost or local ip. But why can't I create a socket server with my public ip? When I try to do this in python, it complains "cannot assign requested address". import socket s=socket.socket() host="address" port=5000 s.bind((host, port)) s.listen(5) while True: c, addr=s.accept() result=c.recv(1024) print(result.decode('utf-8')) c.send(""" test """.encode('utf-8')) c.close() My IP I got from this website:http://whatismyip.host/ 回答1: A

How do I view the full TCP packet that Apache Kafka produces?

て烟熏妆下的殇ゞ 提交于 2021-02-08 10:01:32
问题 I am using Apache Kafka. I use KafkaProducer to produce data and KafkaConsumer to consume data. My config data is: Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ProducerConfig.CLIENT_ID_CONFIG, "DemoProducer"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.IntegerSerializer"); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization

How do I view the full TCP packet that Apache Kafka produces?

女生的网名这么多〃 提交于 2021-02-08 10:01:18
问题 I am using Apache Kafka. I use KafkaProducer to produce data and KafkaConsumer to consume data. My config data is: Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ProducerConfig.CLIENT_ID_CONFIG, "DemoProducer"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.IntegerSerializer"); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization

Receiving data in packets on TCP client

▼魔方 西西 提交于 2021-02-08 09:55:57
问题 Does recv() call intercepts data in packets or can i get data packets with timestamps? 回答1: On a datagram socket (like UDP), recv gets data in datagrams. TCP is a stream-mode socket, however, and recv gets a collection of bytes with no regard for packets. It's possible, using low-level APIs, to get the packets, but if you were hoping to see boundaries between send calls you are out of luck... that information is not present in the packets. 回答2: Recv gets data from a socket that has been

Receiving data in packets on TCP client

纵然是瞬间 提交于 2021-02-08 09:55:52
问题 Does recv() call intercepts data in packets or can i get data packets with timestamps? 回答1: On a datagram socket (like UDP), recv gets data in datagrams. TCP is a stream-mode socket, however, and recv gets a collection of bytes with no regard for packets. It's possible, using low-level APIs, to get the packets, but if you were hoping to see boundaries between send calls you are out of luck... that information is not present in the packets. 回答2: Recv gets data from a socket that has been

TCP - possible for same client-side port to be used for different connections by different applications simlutaneously?

一世执手 提交于 2021-02-08 09:25:29
问题 Is it possible in TCP for different processes not sharing the same executable image (so no fork() for example) to use a same client-side port on Windows, Linux or OSX? This is specifically related to the socket options SO_REUSEADDR and SO_REUSEPORT set using setsockopt() I believe. As far as I've read, I believe it is possible for the same process/image to do this, but I haven't found information as to multiple processes/images. I would imagine it is theoretically possible since each socket

Can one reliably connect a TCP socket to itself?

蓝咒 提交于 2021-02-08 08:33:29
问题 I am wondering whether it is possible to reliably connect a TCP socket to itself -- that is, to get just one socket where whatever you send() on you receive back through recv(). I saw that this can happen (e.g., here, here, and here), but none of these posts explain how to do this programmatically and reliably (i.e., this is usually touted as a curiosity, rather than a feature one would use deliberately). I'm interested in a solution for Windows, Mac, and Linux. Just for completeness, please

C++ Disable Delayed Ack on Windows

别说谁变了你拦得住时间么 提交于 2021-02-08 04:56:32
问题 I am trying to replicate a real time application on a windows computer to be able to debug and make changes easier, but I ran into issue with Delayed Ack. I have already disabled nagle and confirmed that it improve the speed a bit. When sending a lots of small packets, window doesn't ACK right away and delay it by 200 ms. Doing more research about it, I came across this. Problem with changing the registry value is that, it will affect the whole system rather than just the application that I