01-26-2011
Automatic port selection using C in Linux?
Hi
What would be the correct way to get the port number for a free port, using C in Linux?
I've tried to create() and bind() a socket without specifying the port, and that seems to work in some cases (using gcc, and some Linux dist).
When compiling with the Intel Icc64 compiler I suddenly had to do a "dummy send" with the created socket to get a port != 0.
Then, when using that technique on mashines running Slackware 13, it doesn't work. I just get the port to be 0.
So, is there a "correct" way to do this?
I'm trying to find out free port numbers that clients can use to receive messages from a server, and I would like to retreive them before actually sending anything between server/client.
Help, please...
/GC
9 More Discussions You Might Find Interesting
1. Linux
what is the speciality of fortran to be used while porting linux to
other language? (1 Reply)
Discussion started by: sravus
1 Replies
2. Linux
I looking for someone who can help me port a Linux Driver to a OpenBSD( OS X ) Unix Driver. The driver is for a Logic Controls LD9000 USB Customer Display. The currently don't have a driver for the mac operating system, but they do however have one for the Linux OS.
So, I am just trying to... (8 Replies)
Discussion started by: ghost1
8 Replies
3. Linux
All,
I have to servers (NT and REL4).
We can access the application on NT from Linux but we cannot access the applications on Linux when accessed from NT.
The applicaiton is running on Linux with some IP:Port. When we try to access that application from NT, it says that the port is... (1 Reply)
Discussion started by: The One
1 Replies
4. UNIX for Dummies Questions & Answers
hi there!
can anybody help me on what command will i use for UNIX to generate port numbers? i mean, other than bind? say i want to create a new session, and i dont want to reuse the port that i have used...
please help.
i would appreciate it so much!
with much love,
init6_ (2 Replies)
Discussion started by: init6_
2 Replies
5. IP Networking
Hello everyone.
I am supposed to configure port mirroring on Linux (the LAN traffic needs to be routed to the other interface and passed a copy to network monitoring software):
eth0 - connected to local traffic
eth1 - connected to the Internet
The machine is running CentOS v4.4 (Server... (1 Reply)
Discussion started by: reminiscent
1 Replies
6. Red Hat
Hi All,
we have about 50 RedHat Linux servers (v4.x, 5.x), now we planing to configure those servers to get updates(service packs, security patches...etc) automatically. whats is the best practises to do this.
we also have SLES servers and we use Novell's SMT tool to get updates, we... (15 Replies)
Discussion started by: s_linux
15 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I would like to open a specific port for use with a bespoke application.
Before everyone points me to other threads - I read a few but couldn't find any specific to my problem.
Iptables / firewall is disabled
SELinux is also disabled
I would just like to assign this port to this... (0 Replies)
Discussion started by: mcclunyboy
0 Replies
8. UNIX for Advanced & Expert Users
hi experts,
I'm using Linux Centos kernel 2.6
Here is the print out of some my port :
tcp 0 0 127.0.0.1:10080 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:10081 0.0.0.0:* LISTEN
tcp 0 0... (4 Replies)
Discussion started by: justbow
4 Replies
9. Solaris
please find the below o/p for your reference
bash-3.00# fcinfo hba-port
HBA Port WWN: 21000024ff295a34
OS Device Name: /dev/cfg/c2
Manufacturer: QLogic Corp.
Model: 375-3356-02
Firmware Version: 05.03.02
FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies
LEARN ABOUT DEBIAN
efax-gtk-socket-client
efax-gtk-socket-client(1) General Commands Manual efax-gtk-socket-client(1)
NAME
efax-gtk-socket-client - a client of efax-gtk to work with lpd/lprng
SYNOPSIS
efax-gtk-socket-client [hostname] [port]
DESCRIPTION
This program enables lpd/lprng to access the efax-gtk socket server. Meaning the user can send faxes to a printer, which will ack as a fax.
It takes two arguments - first a hostname to connect to, and secondly a port number at that hostname to connect to. All efax-gtk-socket-
client does is to read from standard input (in this case from lpd/lprng) and passes it to a socket at the hostname and port number passed
as arguments to it (namely the hostname of the computer efax-gtk is running on - normally you would specify localhost - and the port number
of the socket).
fax:
:sd=/var/spool/fax:
:mx#0:
:sh:
:lp=/dev/null:
:if=/var/spool/fax/efax-gtk-faxfilter:
This will cause a printer by the name of "fax" to be available, which (if printed to) will send the file to the efax-gtk socket server. If
you set efax-gtk to listen on a port other than port 9900, you will need to amend the file /var/spool/fax/efax-gtk-faxfilter by hand to
specify the correct port number on which efax-gtk is listening.
Don't forget to restart the lpd printer daemon after amending /etc/printcap.
OPTIONS
[ hostname ] - The name of the host to listen to. Usually should be locahlhost.
[ port ] - the port number to listen to on the [ hostname ].
SEE ALSO
efax(1), efax-gtk(1).
AUTHOR
efax-gtk-socket-client was written by Chris Vine <chris@cvine.freeserve.co.uk>.
This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others).
July 18, 2006 efax-gtk-socket-client(1)