network-programming

how to get the tcp header of a received packet in socket programming?

痞子三分冷 提交于 2019-12-31 06:30:50
问题 I want to get the TCP header of each received TCP packet (destined for a specific program,namely, a port) it seems not possible to use recv() or recvfrom() to get the TCP header using regular socket. So, I want to use raw socket with raw socket, I can use recvfrom() to receive all IP packets destined to the host if the host receives a lot packets, I need to check the port number of each packet so see whether it is the needed. then it could be very time and CPU comsuming? while() { recvfrom();

how to get the tcp header of a received packet in socket programming?

亡梦爱人 提交于 2019-12-31 06:29:02
问题 I want to get the TCP header of each received TCP packet (destined for a specific program,namely, a port) it seems not possible to use recv() or recvfrom() to get the TCP header using regular socket. So, I want to use raw socket with raw socket, I can use recvfrom() to receive all IP packets destined to the host if the host receives a lot packets, I need to check the port number of each packet so see whether it is the needed. then it could be very time and CPU comsuming? while() { recvfrom();

Listening to two ports simultaneously in Java server using multithreading

老子叫甜甜 提交于 2019-12-31 05:12:18
问题 I am building a simple Java server which simultaneously listens for client request on two ports simultaneously using two ServerSocket instances. Here is the code for Server: import java.io.PrintWriter; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; class Socket1 implements Runnable { public void run() { try { ServerSocket serverSock=new ServerSocket(5000); while(true) { Socket sock=serverSock.accept(); PrintWriter writer=new PrintWriter(sock.getOutputStream

Implementing DHCP client

爷,独闯天下 提交于 2019-12-30 10:30:10
问题 On unix using C, my client is listening on port 68 with superuser mode. After sending DHCP discover message, when I try to receive, it blocks in recvfrom means there is no message received or is it like system has a process (DHCP client) listening on same port 68 which receives the message and thats my process are not able to receive the message. What is the problem? I have set the socket option SO_REUSEADDR and SO_BROADCAST. I am sending to port 67. struct dhcpmessage { uint8_t op; uint8_t

Disable Nagle's algorithm for NSOutputStream

时光怂恿深爱的人放手 提交于 2019-12-30 06:53:08
问题 I am creating a multiplayer game using MPCF. You control a spacehip on the iPad using the iPhone. I am experiencing various amount of lag and latency and buffering/pauses at random times and intervals and have now landed on Apples Technical Q&A NW26 paper that talks about disabled the Nagle Algorithm. Im trying it out but my program keeps crashing and I dont understand why. It seem to be that CFWriteStreamCopyProperty always return NULL. - (void)stream:(NSStream *)stream handleEvent:

Processing packets with unknown IPv6 extension headers

时间秒杀一切 提交于 2019-12-30 06:24:34
问题 Question Should one discard a packet with an unknown IPv6 extension header? Details I could not find an answer to this question by examining the RFC. The book IPv6 Essentials states on page 22: If a node is required the next header but cannot identify the value in the Next Header field, it is required to discard the packet and send an ICMPv6 Parameter Problem message back to the source of the packet. I read this as: a IPv6 packet with a custom extension header cannot will be dropped unless

Hearing the Incoming audio from mic

ぃ、小莉子 提交于 2019-12-30 05:37:04
问题 i just want to hear what i say to microphone using NAudio and this is my code so far but the problem is i can't hear anything. any help would be appreciated. public partial class frmMain : Form { private WaveIn waveIn; // Gets an audio from microphone private WaveOut waveOut; // Sends audio to speaker private BufferedWaveProvider waveProvider; // Gets an audio from stream public frmMain() { InitializeComponent(); } private void frmMain_Load(object sender, EventArgs e) { waveOut = new WaveOut(

Software to receive printjobs and forward them to printers in a LAN

时光毁灭记忆、已成空白 提交于 2019-12-30 05:27:10
问题 I want to create a software which windows will detect it as a installed printer driver and list that software under "Devices and Printers" Just like the ImagePrinter sowftware, you can access it through following link. http://sourceforge.net/projects/imageprinter/ when this Image Printer is installed on a computer, windows lists it under Printers and Devices so we can right click and share it in our network. LAN users can add this as a remote printer and send print jobs to it, which it will

TCP, HTTP and the Multi-Threading Sweet Spot

99封情书 提交于 2019-12-30 05:02:14
问题 I'm trying to understand the performance numbers I'm getting and how to determine the optimal number of threads. See the bottom of this post for my results I wrote an experimental multi-threaded web client in perl which downloads a page, grabs the source for each image tag and downloads the image - discarding the data. It uses a non-blocking connect with an initial per file timeout of 10 seconds which doubles after each timeout and retry. It also caches IP addresses so each thread only has to

Read SSL Certificate Details on WP8

我与影子孤独终老i 提交于 2019-12-30 04:58:08
问题 I want to read certificate details (e.g. expiration date or CN) for security reasons. Usually there are some properties in network classes available, that allow to check the certificate. This is missing in WP8 implementations. Also I tried to create an SslStream but also there is no way to get any certificate detail like the RemoteCertificate on .net 4.5. var sslStream = new SslStream(new NetworkStream(e.ConnectSocket)); The SslStream is missing everything relating security. So it looks like