I need a simple socket example in free pascal for windows and linux platform.
Mailing lists / fpc-pascal / 2003-07
socket example
9 messages · 1 person ·
- HHarald Houppermans 9
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
I need a simple socket example in free pascal for windows and linux platform.
I found the documentation in the free pascal distribution...
I will now try to make my own example :D
MySocket := socket( AF_INET, SOCK_DGRAM, PF_INET );This call fails with socket error 10043
I am guessing protocol not supported ?
Do I need to start winsock first or something...
I would like to work with the udp protocol.
This does seem to work but if it is usefull ?
MySocket := socket( AF_INET, SOCK_DGRAM, PF_UNSPEC );MySocket := socket( AF_INET, SOCK_DGRAM, PF_INET ); This call fails with socket error…
Well... whatta ya know... :)
sending udp packets actually works :D
MySocket := socket( AF_INET, SOCK_DGRAM, PF_INET ); This call fails with socket error…
In windows that is...
Now trying for linux :D
MySocket := socket( AF_INET, SOCK_DGRAM, PF_INET ); This call fails with socket error…
Wow..
Sending udp packets works for linux too...
Exactly the same code :)
Just cross compiled lol.
:D
What my program would need is:
When a packet is received:
source address and source port
When sending a packet...
supplieing a
dest address and dest port.
The last could be done with connect.
How to do the first is now the question...
Maybe with recv... but the doc says it needs to be in a connected state?
Also maybe with getpeername
This seems to be a weird way of working with datagrams...
Wow.. Sending udp packets works for linux too... Exactly the same code :) Just cross…
Wow it seems the socket unit documentation is way out of date.
I check the source...
sockets.pp uses winsock :D
sockets has a lot more functions :D
