network-programming

C# Game Network Library

风格不统一 提交于 2019-12-30 04:57:10
问题 I am developing an online strategy game using .Net v2. Although the game is primarily strategic, it does have some tactical elements that require reasonable network performance. I plan to use TCP packets for strategic data and UDP packets for tactical data. {EDIT} I forgot to mention that I am leaning away from WCF and .NET 3+ for a couple of reasons. First, because I want to keep my download small and most of my customers already have .NET 2.0. Second, because I would like to have the option

what is stub on the “server” and what does skeleton mean?

浪尽此生 提交于 2019-12-30 03:43:14
问题 What does stub do on the server side ? And what is a skeleton ? This is a diagram from wikipedia. I installed stub both on the server machine and the client machine. I understand that stub helps in the networking on the client side but what does stub do on the server side ? Also in the above figure what does skeleton mean ? 回答1: look at the followed picture: To be short, stub and skeleton are counterparts in a web service setup. Skeleton belongs to service provider side and stub belongs to

How to create a duplex connection using TcpListener and TcpClient?

。_饼干妹妹 提交于 2019-12-30 03:37:12
问题 I have a situation where I need to send and receive information parallelly. My protocol can define a read port and a write port. I currently have the following code: public void Listen() { ThreadPool.SetMinThreads(50, 50); listener.Start(); while (true) { var context = new ListeningContext(listener.AcceptTcpClient(), WritePort); } } How can I create another listener from the TcpClient I am passing? 回答1: A TcpClient object wraps a NetworkStream object. You use the GetStream() method of

JmDNS service discovery in client-server

戏子无情 提交于 2019-12-30 00:44:34
问题 I'm trying to enable service discovery in my client-server application using JmDNS. I fully understand service registry on the server side, with code that resembles this: JmDNS jmdns = JmDNS.create(localhost); jmdns.register(serviceInfo); However, I'm having trouble figuring out how to have my client retrieve the port number and IP address from the registered service and use this data to open a TCP connection. I've searched for examples of how to use JmDNS but to no avail. Can anyone here

Getting started with client-server networking [closed]

你说的曾经没有我的故事 提交于 2019-12-29 14:59:15
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 months ago . I'm a good programmer, but I have zero network experience. Basically, I'd like to get into client-server networking. For example, I'd like to try getting a server process going which allows clients to connect over the internet and send pings to all of the other connected clients. Then maybe I'll try developing

Pass connected SSL Socket to another Process

流过昼夜 提交于 2019-12-29 09:22:20
问题 I am struggling to find a mechanism to send a request to the target server and when the socket has data to be read, pass the socket to another process for getting the data out. I came so far using epoll on Linux, to implement it to the point that i do the handshake, i send the request and the request arrives, then i pass the socket fd to another process for futher handling, i explicitly save the SSL Session using PEM_write_bio_SSL_SESSION and then read it using PEM_read_bio_SSL_SESSION and

Pass connected SSL Socket to another Process

别说谁变了你拦得住时间么 提交于 2019-12-29 09:22:14
问题 I am struggling to find a mechanism to send a request to the target server and when the socket has data to be read, pass the socket to another process for getting the data out. I came so far using epoll on Linux, to implement it to the point that i do the handshake, i send the request and the request arrives, then i pass the socket fd to another process for futher handling, i explicitly save the SSL Session using PEM_write_bio_SSL_SESSION and then read it using PEM_read_bio_SSL_SESSION and

C code to get the IP address

Deadly 提交于 2019-12-29 07:16:07
问题 How do I get the IP address of the local machine using C code? If there are multiple Interfaces then I should be able to display the IP address of each interface. NOTE: Do not use any commands like ifconfig within C code to retrieve the IP address. 回答1: #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> #include <net/if.h> int main() { int fd; struct ifreq ifr; fd = socket(AF_INET, SOCK_DGRAM, 0); ifr.ifr_addr

How to manage endianess of double from network

笑着哭i 提交于 2019-12-29 07:11:48
问题 I have a BIG problem with the answer to this question Swap bits in c++ for a double Yet, this question is more or less what I search for: I receive a double from the network and I want to encoded it properly in my machine. In the case I receive an int I perform this code using ntohl : int * piData = reinterpret_cast<int*>((void*)pData); //manage endianness of incomming network data unsigned long ulValue = ntohl(*piData); int iValue = static_cast<int>(ulValue); But in the case I receive an

simplest way to send raw Byte-arrays using Ruby's TCPSocket-Class

百般思念 提交于 2019-12-29 06:33:06
问题 i want to send raw bytes using Rubys TCPSocket-Class. Has someone a good example? I've tried it in this way, but it does not work :( require 'socket' host = '192.168.0.80' port = 102 s = TCPSocket.new(host, port) s.write [0x03, 0x00, 0x00, 0x16, 0x11, 0xE0, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC1, 0x02, 0x02, 0x02, 0xC2, 0x02, 0x02, 0x02, 0xC0, 0x01, 0x0A ].pack('C') puts s.read s.close puts "exit" thanks :) 回答1: Try using a "*" after the format directive to eat all the elements in the list: s