Loading ...
Sorry, an error occurred while loading the content.

RE: RE: [BPQ32] socket interface / python

Expand Messages
  • sholtofish
    Thanks John. Adding CMS=1 works. My test server didn t however so I modified some code that does (I call this command ECHO in the config file) from socket
    Message 1 of 4 , Oct 2, 2013
    • 0 Attachment

      Thanks John. Adding CMS=1 works.


      My test server didn't however so I modified some code that does (I call this command "ECHO" in the config file)


      from socket import *
      import threading
      import thread

      def handler(clientsock,addr):
          while 1:
              data = clientsock.recv(BUFSIZ)
              if not data:
                  break
              if len(data)>1:
                 msg = 'echoed:... ' + data
                 clientsock.send(msg)

              if data.find("quit")<>-1:
                  clientsock.close()
                  break
          clientsock.close()

      if __name__=='__main__':
          HOST = 'localhost'
          PORT = 8050
          BUFSIZ = 1024
          ADDR = (HOST, PORT)
          serversock = socket(AF_INET, SOCK_STREAM)
          serversock.bind(ADDR)
          serversock.listen(2)

          while 1:
              print 'waiting for connection...'
              clientsock, addr = serversock.accept()
              clientsock.send("Type 'quit' to return to node\r\n");
              print '...connected from:', addr
              thread.start_new_thread(handler, (clientsock, addr))



      ---In BPQ32@yahoogroups.com, <bpq32@yahoogroups.com> wrote:

      Sholto,
       
      The number after the word HOST is an index into the list of port numbers, so
       
      APPLICATION 4,DEMO,C 2 HOST 0 S

      will conenct you to port 23. You need
       
      APPLICATION 4,DEMO,C 2 HOST 1 S

      to connect to port 8050.
       
      However, this isn't causing the "Error - Invalid Command". i've just checked the code, and the connect to HOST will only work if you also have CMS=1 in your Telnet Server Config. This will be fixed in the next release.
       
      73, John
       

      From: BPQ32@yahoogroups.com [mailto:BPQ32@yahoogroups.com] On Behalf Of k7tmg@...
      Sent: 02 October 2013 21:30
      To: BPQ32@yahoogroups.com
      Subject: [BPQ32] socket interface / python

       

      Hi John,

      I'm trying the socket interface you created for linbpq (on Windows).

      I added this into the telnet port definition:
      CMDPORT 23 8050

      My applications look like this:
      APPLICATION 1,BBS,,K7TMG-1,TMGBBS,1
      APPLICATION 2,TERM,,K7TMG,#TMGTRM,1
      APPLICATION 3,CHAT,,K7TMG-4,TMGCHT,1
      APPLICATION 4,DEMO,C 2 HOST 0 S

      And I have a very simple python program running a "test server" on port 8050. I can telnet to it from the command line but when I type 'demo' into the bpq terminal I get

      demo
      Error - Invalid Command
      Returned to Node IDA105:K7TMG-7

      So any clue what I am doing wrong?

      73

      Sholto
      K7TMG


      Python test server app (I run it in v2.7):

      #!/usr/bin/env python

      """
      A simple test server
      """

      import socket

      host = 'localhost'
      port = 8050
      backlog = 5
      size = 1024
      s = socket.socket(socket .AF_INET, socket.SOCK_STREAM)
      s.bind((host,port))
      s.listen(backlog)
      while 1:
          client, address = s.accept()
          client.send("The quick brown fox jumps over the lazy dog.")
          client.close()

    Your message has been successfully submitted and would be delivered to recipients shortly.