Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11

    Arrow Anyone know the command for connecting to someones IP address??


    Basically I want to be able to connect to someones ip address so that I could creat a instant messenger. Anyone have any idea first of all what I am talking about and what the command is to connect using an IP address so I can create an instant messenger.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    I would really apreciate it if someone could provide an example or tell me a command I can use or something.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    133
    Rep Power
    12
    The Official Python Documentation comes in handy: Python Library Reference > Socket > Example.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    Thanx but It is a little complicated I just want a simple format on what command and how to use it.
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    It really depending on exactly what you want to do there are a few modules that can connect to various places - websites, email accounts etc. And all of these are built ontop of the 'socket' module...

    Unfortunatly i agree. Pretty low level stuff! Anyway check out these few although if you want to do anything "original" you'll end up back where perc pointed you

    http://www.python.org/doc/2.3.3/lib/module-smtplib.html
    http://www.python.org/doc/2.3.3/lib/module-httplib.html
    http://www.python.org/doc/2.3.3/lib/...telnetlib.html

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    So the link you guys sent me says I must do this for a basic connection.

    # Echo server program
    import socket

    HOST = '' # Symbolic name meaning the local host
    PORT = 50007 # Arbitrary non-privileged port
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, PORT))
    s.listen(1)
    conn, addr = s.accept()
    print 'Connected by', addr
    while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
    conn.close()


    # Echo client program
    import socket

    HOST = 'daring.cwi.nl' # The remote host
    PORT = 50007 # The same port as used by the server
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    s.send('Hello, world')
    data = s.recv(1024)
    s.close()
    print 'Received', `data`
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    133
    Rep Power
    12
    Originally Posted by reaper69
    Thanx but It is a little complicated I just want a simple format on what command and how to use it.
    There isn't anything such as a simple command. If you want to connect to another computer you'll need at least one client and one server. In some cases the server isn't what you care about such as when you connect to a website but there still is a server and a client involved.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    Ok , now if that code is correct for a basic connection I just want to make an instant messenger.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    217
    Rep Power
    0
    Originally Posted by reaper69
    Ok , now if that code is correct for a basic connection I just want to make an instant messenger.
    Well it takes quite a bit to make a functional instant messenger. It's acutaly what I am doing right now. The instant messenger server is around 230 lines at the moment and it's not done yet. I havn't even started the client .

    If it is just a client that you want to make (to connect to an existing service) you might be able to find some libs for it. I know there is one for MSN: http://msnp.sourceforge.net/tutorial.html

    HTH, Chris.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    This is my first instant messenger I just want to make a little program to connect to my friends computer and only talk to him. Just a quickprogram that when it runs it will connnect to his computer and we will be able to send messeges. I am finished with everything I just need to connect to his computer. When you get done send me a copy of your instant messenger I would like to see what a real IM program looks like. And don't worry I am not stupid anough to plagerise.


    p.s. my email adress is luckyboy17@hotmail.com.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    217
    Rep Power
    0
    When it is done, I will send you it. I wouldn't mind if you used my code anyway, I am only learning too .

    BTW, if you just need the code to connect to his computer, here it is:

    Code:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # TCP
    
    # Change these.
    host = '127.0.0.1' 
    port = 50007	
    
    sock.connect((host, port))
    then you use sock.send(<data>) and sock.recv(<bufsize>) to send and receive. <bufsize> is the max data you receive at once (in bytes) and <data> is a string of data. Oh, and sock.close() to close the socket .

    HTH, Chris.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    30
    Rep Power
    11
    Ok thanx for the help. Hope to talk to you again.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    I haven't delved too much into network programming yet. However, you can also use python's os module and pass your intentions as arguments to the sys method.
    Code:
    Import os
    os.system("ping ipaddy")
    dosomething()
    dosomething()
    basically whatever you can do from the cmd lind the os.system is there to facilitate that for you.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    It would be easier to run an XML-RPC Server on each machine (it really would).

    Why? It abstracts away all the detailed stuff about network connections, timeouts, data length, and so on, leaving you with just a couple of connection lines of code.

    Server:
    Code:
    from SimpleXMLRPCServer import SimpleXMLRPCServer
    
    class say(msg):
        print msg
    
    # Create the server
    server = SimpleXMLRPCServer(("localhost", <port>))
    server.register_function(say)
    server.serve_forever()
    ---------------------------------

    Client:
    Code:
    # import library
    from xmlrpclib import Server
    
    # Connect to the other computer
    remote_computer = Server('http://<friends IP>:<port>')
    
    # Send messages.
    message = 'Client connected'
    
    while message:
        remote_computer.say(message)
        message = raw_input("Type here: ")
    Run both on both computers, and adjust for IP/Ports as necessary.
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    3
    Rep Power
    0

    I believe this is what you are refering to


    Path: Start>Programs>Accessories>Command Prompt
    When you open Command Prompt you can get your IP address by typing in ipconfig and hitting the enter key. You and the other user will need to know this information. So you will have to show them how to get their IP address. This is different than the IP address websites will give you. This is LAN the public one is WAN. You want LAN. OK to the juicy part. You are going to type in the following: net send (ip address of friends computer goes here) " message with quotation marks" then just hit enter. i.e. C:\net send 192.168.1.54 "Hey buddy just playing on the puter, and thought about you. Want to come over, and watch the game?"
    You need to make sure that this messenger service is enabled. Do a Google search for net send. You will find a site I am sure that tells you how to turn it on and off. By default it is on so I would just try the first steps I gave you, and see if that works. E-mail me if that's it because I love being right all the time.
    Last edited by babycody; May 8th, 2004 at 12:15 AM.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo