Cat /proc/sys/net/ipv4/ip_local_port_range


 
Thread Tools Search this Thread
Special Forums IP Networking Cat /proc/sys/net/ipv4/ip_local_port_range
# 1  
Old 11-11-2014
Cat /proc/sys/net/ipv4/ip_local_port_range

Hello,

Code:
/proc/sys/net/ipv4/ip_local_port_range returns 32000 - 61000,

i have a client TCP and a Server TCP. i have used bind() only on the server, the port of socket client is given by the OS that's it ?
it retrieves this port from this range (/proc/sys/net/ipv4/ip_local_port_range) ?

That's it ?


Thanks a lot.
Best Regards.

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks
# 2  
Old 11-11-2014
Yup, first and last local port number available, that's it.
# 3  
Old 11-11-2014
Ok, but when i use:


Code:
 printf("%d", ClientAddr.sin_port);

it display a value (29000) not in this range 32000- 61000


Have you an explanation please ?

Thanks a lot.
Best Regards.
# 4  
Old 11-11-2014
and when you
Code:
printf"%d", htons(ClientAddr.sin_port);

# 5  
Old 11-11-2014
I have set this code:

Code:
printf"%d", htons(ClientAddr.sin_port);

in
Code:
the Server.c

after the system call
Code:
Accept()

So it's htons or ntohs ?

Thanks a lot.
# 6  
Old 11-13-2014
They're symmetric, so it doesn't matter. Whether you're converting to or from the network, the bytes get rearranged the exact same way.

Not all systems need to swap bytes at all; big-endian machines already keep their bytes in the proper order. On these machines, ntohs(), etc. do nothing at all.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

2. Red Hat

Disable IPV4

Hi im using Redhat Ver 6.4 is it possible to disable IPV4 and use only IPV6? how can i do that? thanks Guy (2 Replies)
Discussion started by: guy3145
2 Replies

3. UNIX for Advanced & Expert Users

echo 1 > /proc/sys/vm/drop_caches a good idea?

Hi folks. I work with several production servers, and I have seen in some Kernel Cache using most of the memory. See this pic: http://i51.tinypic.com/301nb6c.jpg Do you think this is a smart choice? Remember these are productions servers and it is extremely necesary this does not... (6 Replies)
Discussion started by: erick_tuk
6 Replies

4. UNIX for Dummies Questions & Answers

_/proc/stat vs /proc/uptime

Hi, I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies

5. Linux

Kernal panic error& setuproot:error mounting /proc&/sys

Hi all, I am new to redhat/fedora linux. In fedora linux 6,we created one file system(hda3 - /fs). in this mount poing we were installed mounta vista os. while booting we are getting below error messages. 1) Booting 'mountaVisat(2.6.18_pro 500_pc_target-x86_586 smp)' root(hd0,1)... (2 Replies)
Discussion started by: arjunreddy3
2 Replies

6. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

7. Shell Programming and Scripting

Parsing /proc/net/dev into key:value pairs (self-answered)

Hi all, I need some help with using sed/awk/other linux tools to meet the following goal: I'm trying to take the output of /proc/net/dev: Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes ... (0 Replies)
Discussion started by: felbane
0 Replies

8. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

9. Shell Programming and Scripting

cat /proc/ files

Hi, I need to write a shell script that should lists only the files that starts with alphabet from the /proc dir and then I have to cat those files and redirect to a file. But my below script is not working. It is reading the first file properly but not the subsequent files. Please throw a... (2 Replies)
Discussion started by: royalibrahim
2 Replies
Login or Register to Ask a Question