Skip to content
Advertisement

Tag: sockets

Simple socket forwarding in linux

The scenario is pretty simple: Using TCP/IP I have a client which connects to me (server) I want to forward the data the socket sends me to another socket which I opened and the data I received from that socket backwards.Just like a proxy. Right now I have 1 thread one who listens from incoming connection and spawns another 2

Linux/Unix Socket Self-connection

When a client try to connect to a server, if client and server are both localhost, self-connection may happen(source port and destination port happened to be the same.). But my problem is, client is not listening to that port, how can self-connection be possible? Answer We can simple reproduce this phenomenon with the following python program when we try to

How to prevent kernel from passing packets to network layer?

Frames received by the network card will be handled by the driver and then passed to the upper layer of the protocol stack by the Linux kernel. Is there an easy way to prevent the kernel from passing packets to network layer? So that I can receive the frames from datalink layer and handle all the packets by myself(perhaps application

How to completely destroy a socket connection in C

I have made a chat client in linux using socket, and i wish to destroy the connection completely. Following is the relevant portions of the code: but the close(sock) doesnot seem to close the destroy the connection completely, because after going to ‘label’ the code is exiting showing the error message That is the connection is not happening again. What

Can Python select what network adapter when opening a socket?

The target machine running the python application will have three network interfaces available to it. In general all three networks will be vastly different, however there is a possibility that two of the three could be on similar networks. In the example below I do not have control over the destination address on ETH 2 (as it a pre-configured system),

Socket data length questions

I have a couple of questions related to the following code: The questions: Why I read 255 not 256 ? Let’s say I want to send the word: “Cool” from the client to the server. How many bytes should I write “in client” and how many bytes should i read “in the server”? I’m really confused. Answer You already have

Advertisement