LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-29-2015, 06:26 AM   #1
bobdxcool
LQ Newbie
 
Registered: Jun 2014
Posts: 5

Rep: Reputation: Disabled
Opening a TCP port in Linux


I am trying to establish a TCP socket between my linux server and my client running on my laptop. The TCP server code I am running is,

Code:
from socket import *

    HOST = ''
    PORT = 1999
    serversocket = socket(AF_INET,SOCK_STREAM)
    serversocket.bind((HOST,PORT))
    serversocket.listen(5)
    while True:
        (clientsocket, address) = serversocket.accept()
        print ("Got client request from",address)
        clientsocket.send("Thank You for connecting")
        clientsocket.close()
The TCP client code I am running is :

Code:
from socket import *

clientsocket = socket(AF_INET,SOCK_STREAM)

clientsocket.connect(("my-server-ip-address",1999))

recv = clientsocket.recv(1024)

print(recv)
The problem I am facing is that I am not able to communicate with the server from my client. WHen I run both the TCP client and server code on my linux server, the communication works. So, I have narrowed down this issue to lack of open TCP ports on my server. I am using windows 8 on my laptop. I did an nmap from my laptop to my server and the list of open ports available were, 80/tcp, 443/tcp,22/tcp. So, can anyone suggest on how to add a port to the list of open ports. For example, in this case I need to add 1999 to the list of open ports.

Server version: Linux hostname 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
 
Old 03-29-2015, 07:25 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
I here assume iptables is used directly, without any special frontend.
In cli you can configure iptables like so:
iptables -A INPUT -p tcp --dport 1999 -j ACCEPT
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[solved]Redirect TCP port 25 to port 2525 sandilovely24 Linux - Security 2 02-03-2014 08:20 AM
how to open tcp port 8080 in redhat linux shankarpanda003 Linux - Newbie 2 01-04-2013 02:04 AM
Opening one TCP port from DMZ into LAN aaviad Linux - Security 2 06-17-2005 08:31 AM
Opening a Linux port on Squid David@330 Linux - Newbie 3 03-15-2005 06:17 PM
close port 6000/tcp 515/tcp SchwipSchwap Linux - Newbie 1 09-12-2002 08:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration