Configure a range of ports to "socket" system call
Hello ;
This what i want to do :
I know that in the system call
you can specify the local port for your socket, but im using a private library , and im sure that in that library they call bind with port "0" (so operative system return a random port between dynamic defined ports) ; i know cause the port assigned is always different.
I need that the system's call " bind (to bind a socket id to a local port) taking a port number that i can configure before call it.
i've been analysing the file "/etc/services" , there i can see numbers of differents ports associated to a System Service or Common accepted services. Always one port , not a range.
Can i define a range of ports (pool) to the call "bind -with 0-" to take a number from this pool??? If so, is this in relation with "/etc/services"
Thx everybody.
---------- Post updated at 03:54 PM ---------- Previous update was at 12:24 PM ----------
Like ever.....i always finished responding my own questions....
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Hi,
I am having an issue with using sockets.
I have a program which binds to a socket and listen on it. Later I spawn a thread to handle some function. In the new thread created I need to call a shell script which executes the specified function. Here I am using a system command to call the... (5 Replies)
been a while so i'm a bit rusty and need a little help. writing a script that needs to compare $EXECHOST(a number) against a numerical range and then set a value. below isn't working but should give you folks an idea of my goal:
if ; then
echo "This is a 32B machine, exiting..."
if ;... (4 Replies)
I'm trying to add a custom ("Hello world" :o) system call.
In /usr/src/linux/hello/ I put simple hello.c ...#include "linux/linkage.h" // for linking a system call
#include "linux/kernel.h" // for "printk"
asmlinkage int sys_hello()
{
printk(KERN_ALERT "Hello!");
return 1;
}... and in... (5 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hello experts!
I need your help please
I have a file.txt of which I want to extract 3rd and 4th columns with date with the form e.g.:
2016-11-25 03:14:50and pass them to "date" command, but also append the 9th column in a file as well.
So I want to execute
date -d '2016-11-25 03:14:50' ... (2 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Cannot present unpresented disks back again. On a test server tried this as a solution "multipath -r" and it worked. Too worried to try it in production before I know all the information.
Any info would be appreciated!
Also some links to the documentation on this specific issue could help a... (1 Reply)
Discussion started by: jsteppe
1 Replies
LEARN ABOUT NETBSD
bindresvport_sa
BINDRESVPORT(3) BSD Library Functions Manual BINDRESVPORT(3)NAME
bindresvport, bindresvport_sa -- bind a socket to a reserved privileged IP port
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/types.h>
#include <rpc/rpc.h>
int
bindresvport(int sd, struct sockaddr_in *sin);
int
bindresvport_sa(int sd, struct sockaddr *sa);
DESCRIPTION
bindresvport() and bindresvport_sa() are used to bind a socket descriptor to a reserved privileged IP port, that is, a port number in the
range 0-1023. The routine returns 0 if it is successful, otherwise -1 is returned and errno set to reflect the cause of the error.
If sin is a pointer to a struct sockaddr_in then the appropriate fields in the structure should be defined. Note that sin->sin_family must
be initialized to the address family of the socket, passed by sd. If sin->sin_port is '0' then a port (in the range 600-1023) will be cho-
sen, and if bind(2) is successful, the sin->sin_port will be updated to contain the allocated port.
If sin is the NULL pointer, a port will be allocated (as above). However, there is no way for bindresvport() to return the allocated port in
this case. getsockname(2) can be used to determine the assigned port.
Only root can bind to a privileged port; this call will fail for any other users.
Function prototype of bindresvport() is biased to AF_INET socket. bindresvport_sa() acts exactly the same, with more neutral function proto-
type. Note that both functions behave exactly the same, and both support AF_INET6 sockets as well as AF_INET sockets.
RETURN VALUES
If the bind is successful, a 0 value is returned. A return value of -1 indicates an error, which is further specified in the global errno.
ERRORS
[EPFNOSUPPORT] If second argument was supplied, and address family did not match between arguments.
bindresvport() may also fail and set errno for any of the errors specified for the calls bind(2), getsockopt(2), or setsockopt(2).
SEE ALSO bind(2), getsockname(2), getsockopt(2), setsockopt(2), ip(4)BSD January 27, 2007 BSD