소켓 프로그래밍을 하다가 9190 포트로 연결을 하려고 하는데 포트가 닫혀있어서 그런지 아니면 공유기에서 포트를 막아서 그런지 9190포트는 되질 않습니다.. 80 포트로 하니 되더라구요.. 9190포트를 사용하려면 어떻게 해야 할지요??
#include <sys/socket.h> #include 그외 다수들... ... socket() bind() listen() ... cfd = accept();
위와 같은 패턴으로 포트를 엽니다. bind 를 한 순간 이미 sockaddr_in 구조체에서 설정한 port 는 사용이 된것으로 되고, '포트를 열었다.' 를 '접속 가능하다' 라고 해석한다면, accept() 가 그 역할을 하겠죠.
삽질의 대마왕...
설치시에 방화벽을 설정하셨었나요?? 그런 것이라면 iptables -L을 이용하여 확인하여 보시기 바랍니다. 아마도 방화벽 문제일듯 싶은데........
[root@localhost server]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT) target prot opt source destination RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT) target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references) target prot opt source destination ACCEPT all -- anywhere anywhere ACCEPT icmp -- anywhere anywhere icmp any ACCEPT esp -- anywhere anywhere ACCEPT ah -- anywhere anywhere ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns ACCEPT udp -- anywhere anywhere udp dpt:ipp ACCEPT tcp -- anywhere anywhere tcp dpt:ipp ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:telnet ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-ns ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-dgm ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:netbios-ssn ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:microsoft-ds REJECT all -- anywhere anywhere reject-with icmp-host-prohibited [root@localhost server]#
방화벽이 막혀있는건지요???
... ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ...
이게 80포트가 열려 있다는 뜻입니다.
그럼 여기에 9190포트를 여는 방법도 있겠네요??? 어떤 명령어가 있을까요? 제가 알아보니까 iptables -A INPUT -p tcp -dport 9190 -j ACCEPT 아닌가요??
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
#include #include 그외
위와 같은 패턴으로 포트를 엽니다. bind 를 한 순간 이미 sockaddr_in 구조체에서 설정한 port 는 사용이 된것으로 되고, '포트를 열었다.' 를 '접속 가능하다' 라고 해석한다면, accept() 가 그 역할을 하겠죠.
삽질의 대마왕...
삽질의 대마왕...
혹시 방화벽 문제 아닌가요?
설치시에 방화벽을 설정하셨었나요??
그런 것이라면 iptables -L을 이용하여 확인하여 보시기 바랍니다.
아마도 방화벽 문제일듯 싶은데........
iptables -L 다음과 같습니다..
[root@localhost server]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:telnet
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-ns
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:microsoft-ds
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
[root@localhost server]#
방화벽이 막혀있는건지요???
막혀있네요.
...
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
...
이게 80포트가 열려 있다는 뜻입니다.
아~~그렇군요..
그럼 여기에 9190포트를 여는 방법도 있겠네요???
어떤 명령어가 있을까요?
제가 알아보니까
iptables -A INPUT -p tcp -dport 9190 -j ACCEPT
아닌가요??
댓글 달기