Comments (7)
Hi Mahmoud,
I see two possible problems. First, try making the IPC Mode be TX instead of RX. Then, make the number of TX prefixes be 1 instead of zero, and add the line
"SC" ! Prefix 0
It may help if I explain that "Tx" is slang for "transmit" and "Rx" is slang for "receive". If both ends of the socket are in Rx mode, then everyone is listening but no one is talking :-) Also, a non-zero number of TX prefixes are needed for Tx to actually transmit something. If "SC" works for you, then we can talk about how to refine what is being sent.
Your python looks plausible, but I'm not expert enough either in python or sockets to say with confidence.
Regards,
-Eric
from 42.
Okay will try this fix, but not both ends of the socket are TX. one is TX, and the other are RX, but the thing is that Tx and Rx ends are on the same PC device, would that be an issue?
from 42.
No, both ends of the socket can be on the same device with no problem. You have run the TxRx example problem, right?
from 42.
Yes I tried TxRx example, and it works
Here is the new configuration for Inp_IPC of Tx, but still the same issue with Python being the Rx side.
<<<<<<<<<<<<<<< 42: InterProcess Comm Configuration File >>>>>>>>>>>>>>>>
1 ! Number of Sockets
********************************** IPC 0 *****************************
TX ! IPC Mode (OFF,TX,RX,TXRX,ACS,WRITEFILE,READFILE)
0 ! AC.ID for ACS mode
"State00.42" ! File name for WRITE or READ
SERVER ! Socket Role (SERVER,CLIENT,GMSEC_CLIENT)
localhost 10001 ! Server Host Name, Port
TRUE ! Allow Blocking (i.e. wait on RX)
TRUE ! Echo to stdout
1 ! Number of TX prefixes
"SC" ! Prefix 0
And here is the python code
import socket
client_port = 10001
client_host = "127.0.0.1"
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.settimeout(10)
client_socket.bind((client_host, client_port))
read_bytes, read_address = client_socket.recvfrom(1) # buffer size is 1024 bytes
read_byte = read_bytes
client_socket.close()
And this is the error I get
OSError: [Errno 98] Address already in use
The error mentions that address 127.0.0.1 is already in use by Tx, but I think this is the case with TxRx example that both server and client are bound to same address and port, correct?
from 42.
Hi Mahmoud,
Yes I tried TxRx example, and it works
Okay, good. I was confused by your question about both ends of the socket being on the same machine. The TxRx problem demonstrates that.
I can't help you troubleshoot your python code. What I can suggest is that you start with TxRx, then replace the Rx end with your code. Configure your end as much like Rx as you can. See 42ipc.c, Kit/Source/iokit.c, and Source/IPC/*.c for details. Once you get that interface working, the rest is easy ;-)
Happy coding,
-Eric (he/him)
from 42.
Okay sure.
Meanwhile, could you please confirm the following configuration for the TxRx example?
Tx:
- it is the socket server
- its host is 127.0.0.1
- its port is 10001
Rx:
- it is the socket client
- its host is 127.0.0.1
- its port is 10001
Correct?
from 42.
It is working now
I had to replace this line: client_socket.bind((client_host, client_port))
with this: client_socket.connect((client_host, client_port))
import socket
client_port = 10001
client_host = "127.0.0.1"
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM , 0) # AF_INET: IPv4, SOCK_DGRAM: UDP, SOCK_STREAM: TCP
client_socket.setblocking(False)
client_socket.settimeout(10)
client_socket.connect((client_host, client_port))
try:
read_bytes = client_socket.recv(1)
except socket.timeout:
print('WARNING Timedout on receiving bytes from ethernet')
except OSError:
print('Server not connected yet')
client_socket.close()
from 42.
Related Issues (20)
- guidelines for installing on Linux HOT 4
- Issue with external control commands HOT 3
- Orbit propagation consistency HOT 8
- Error in SunVtx Shader compile - For both Demo and Standalone projects HOT 2
- How to give different initial angular velocities of each body? and... HOT 3
- Proximity operations simulation HOT 5
- Isolating the graphics engine HOT 3
- Handling terrain data in OpenGL
- About Star Tracker Valid position HOT 1
- JDtoGPSTime is not correct? HOT 3
- `AC.bvb` field not written on socket HOT 6
- Question about paths and the length of the char arrays for paths HOT 2
- Not seeing regions rendered HOT 1
- Propellant slosh simulation in 42 HOT 2
- How do I share a 12U Cubesat Model?
- Star Tracker makes the SC tumble HOT 1
- GLD_TEXTURE_INDEX_nD warnings HOT 1
- Initializing a new SIM from the conditions of another SIM at a specific time
- Overlapping S/C in OpenGL during close-range rendezvous simulation HOT 1
- PROTOTYPE_FSW doesn't do pointing for my spacecraft HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 42.