socket与tcp连接(代码实例)
程序员文章站
2022-06-30 20:57:40
socket与tcp连接(代码实例)
[oracle@highgo ~]$ ps -ef |grep LOCAL
oracle 31665 1 0 10:10...
socket与tcp连接(代码实例)
[oracle@highgo ~]$ ps -ef |grep LOCAL oracle 31665 1 0 10:10 ? 00:00:00 oracleorcl (LOCAL=NO) oracle 31669 1 0 10:10 ? 00:00:00 oracleorcl (LOCAL=NO) oracle 31673 31584 0 10:11 pts/0 00:00:00 grep --color=auto LOCAL [oracle@highgo ~]$ [oracle@highgo ~]$ [oracle@highgo ~]$ cd /proc [oracle@highgo proc]$ cd 31665 ------->>>>选择31665号操作系统进程 [oracle@highgo 31665]$ ls attr cgroup comm cwd fd io map_files mountinfo net oom_adj pagemap root sessionid stack status timers autogroup clear_refs coredump_filter environ fdinfo limits maps mounts ns oom_score personality sched setgroups stat syscall uid_map auxv cmdline cpuset exe gid_map loginuid mem mountstats numa_maps oom_score_adj projid_map schedstat smaps statm task wchan [oracle@highgo 31665]$ cd fd [oracle@highgo fd]$ ls -lrt total 0 lr-x------ 1 oracle oinstall 64 Feb 25 10:11 8 -> /u01/app/oracle/product/11.2.0/db_home/rdbms/mesg/oraus.msb lr-x------ 1 oracle oinstall 64 Feb 25 10:11 7 -> /u01/app/oracle/product/11.2.0/db_home/rdbms/mesg/orazhs.msb lr-x------ 1 oracle oinstall 64 Feb 25 10:11 6 -> /dev/zero lr-x------ 1 oracle oinstall 64 Feb 25 10:11 5 -> /proc/31665/fd lr-x------ 1 oracle oinstall 64 Feb 25 10:11 4 -> /u01/app/oracle/product/11.2.0/db_home/rdbms/mesg/oraus.msb lr-x------ 1 oracle oinstall 64 Feb 25 10:11 3 -> /dev/null lrwx------ 1 oracle oinstall 64 Feb 25 10:11 257 -> /data/ORCL/datafile/o1_mf_sysaux_f5xj120r_.dbf lrwx------ 1 oracle oinstall 64 Feb 25 10:11 256 -> /data/ORCL/datafile/o1_mf_system_f5xj11z4_.dbf l-wx------ 1 oracle oinstall 64 Feb 25 10:11 2 -> /dev/null lrwx------ 1 oracle oinstall 64 Feb 25 10:11 14 -> socket:[220745]----->>>注意中括号内的数字 l-wx------ 1 oracle oinstall 64 Feb 25 10:11 1 -> /dev/null lr-x------ 1 oracle oinstall 64 Feb 25 10:11 0 -> /dev/null [oracle@highgo fd]$ cat /proc/net/tcp sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 18856 1 ffff881ffc8d0000 100 0 0 10 0 1: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 14792 1 ffff880c34f68000 100 0 0 10 0 2: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 16928 1 ffff880c35af8000 100 0 0 10 0 3: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 22926 1 ffff880c32ae8000 100 0 0 10 0 4: 6A64A8C0:BDA3 6A64A8C0:05F1 01 00000000:00000000 00:00000000 00000000 1200 0 13282 1 ffff880c34300000 20 4 32 10 -1 5: 6A64A8C0:0016 AB50A8C0:FF54 01 00000034:00000000 01:00000017 00000000 0 0 216248 4 ffff880c35fd8000 24 4 31 10 42 [oracle@highgo fd]$ cat /proc/net/tcp6 sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 00000000000000000000000000000000:006F 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 18855 1 ffff881ff4a28000 100 0 0 10 0 1: 00000000000000000000000000000000:4231 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1200 0 13286 1 ffff880c32fc0880 100 0 0 10 0 2: 00000000000000000000000000000000:05F1 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1200 0 25465 1 ffff880c35b60000 100 0 0 10 0 3: 00000000000000000000000000000000:0016 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 14794 1 ffff880c34f50000 100 0 0 10 0 4: 00000000000000000000000001000000:0277 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 16927 1 ffff880c35af0000 100 0 0 10 0 5: 00000000000000000000000001000000:0019 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 22927 1 ffff880c326d0000 100 0 0 10 0 6: 0000000000000000FFFF00006A64A8C0:05F1 0000000000000000FFFF00006A64A8C0:BDA3 01 00000000:00000000 02:0007B0F7 00000000 1200 0 25516 2 ffff880c32fc0000 20 5 31 10 -1 7: 0000000000000000FFFF00006A64A8C0:05F1 0000000000000000FFFF0000AB50A8C0:E858 01 00000000:00000000 02:000ACA90 00000000 1200 0 219660 2 ffff880c19b19100 21 4 33 10 -1 8: 0000000000000000FFFF00006A64A8C0:05F1 0000000000000000FFFF0000AB50A8C0:E84A 01 00000000:00000000 02:000ACA90 00000000 1200 0 220745 2 ffff880c333e1100 21 4 29 10 -1 ----socket四元组:本地ip:本地port 远程ip:远程port------ 00006A64A8C0转换字节序并转换为10进制为192.168.100.106 05F1转换为10进制为1521 AB50A8C0转换字节序并转换为10进制为192.168.80.171 E84A转换为10进制为59466 在windows客户端上,执行如下命令可以验证windows上的59466端口: D:\app\Administrator\product\11.2.0>netstat -ano | findstr 59466 TCP 192.168.80.171:59466 192.168.100.106:1521 ESTABLISHED 41464 D:\app\Administrator\product\11.2.0>