hi all
I'm writing a application which uses Opencv and wxWidgets and sends camera frames via a socket connection. But it seems i'm doing something wrong: after starting a server on my machine, i can't connect my application to the socket the server is listening on...why is that?

import socket 
client=0
 
class SockClient():
    def init1(self,ip,port):
        global client
        client=socket.socket ( socket.AF_INET, socket.SOCK_STREAM) #initiating socket 
        client.bind((ip,int(port)))
        client.settimeout(1)
  
   def kill(self):
         global client
         client.close()
   
   def send(msg,type):
         global client
         if (type==1):
              client.send(type+"#!/"+size+"#!/"+msg)
         elif (type==2):
              print 'not implemented yet'
         elif (type==3):
              print 'not implemented yet'
         else:
              print 'not a valid message type'

this is the error i get:

Traceback (most recent call last):
  File "main.py", line 94, in OnConnect
    client.init1(self.ipBox.GetValue(),self.portBox.GetValue())
  File "/mnt/misc/work/cd/src/sockComm.py", line 9, in init1
    client.bind((ip,int(port)))
  File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use

Don't bind a client socket. Use connect.

oh....my bad!
thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.