--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
This is how my code looks like:
import socket
import select
class ChatServer:
def __init__( self):
self.port = 8880;
self.srvsock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.srvsock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
self.srvsock.bind( ("", 8880) )
self.srvsock.listen( 5 )
print("New socket bind")
while 1:
print("Waiting for new connection")
self.sock,(remhost,remport)=self.accept_new_connection()
print ('ChatServer started on port %s' % port)
def send(self,data):
self.sock.send(data)
def receieve(self):
self.str=sock.recv(1024)
print(self.str)
I want to run this code first time when my project starts and want to call send() and receive() functions from other two different python files located in different path.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/be550507-7ccd-4a99-bd56-cebfda87f24f%40googlegroups.com.
On Tue, Oct 24, 2017, 1:32 AM T Obulesu <obul...@gmail.com> wrote:
This is how my code looks like:
import socket
import select
class ChatServer:
def __init__( self):
self.port = 8880;
self.srvsock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.srvsock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
self.srvsock.bind( ("", 8880) )
self.srvsock.listen( 5 )
print("New socket bind")
while 1:
print("Waiting for new connection")
self.sock,(remhost,remport)=self.accept_new_connection()
print ('ChatServer started on port %s' % port)
def send(self,data):
self.sock.send(data)
def receieve(self):
self.str=sock.recv(1024)
print(self.str)
I want to run this code first time when my project starts and want to call send() and receive() functions from other two different python files located in different path.
Looks like what you want is for your ChatServer to be one class that has the responsibility of accepting socket connections, receiving, and sending for all connected clients. And then you want another class that is a ChatClient which allows a connection to the chat server on port 8880 and let's the client to send and receive messages. Does that sound like the goal? Or are you trying to just establish a bi-directional request/reply between two peers?
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/be550507-7ccd-4a99-bd56-cebfda87f24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/38035268-5d27-416b-982e-4d1607177000%40googlegroups.com.
import socket import logging import pickle class reception_eth: __instance = None #sock=None __name__ = "serial.reception" logger = logging.getLogger(__name__) @staticmethod def getInstance(): """ Static access method. """ if reception_eth.__instance == None: print(reception_eth.__instance) reception_eth() return reception_eth.__instance def __init__(self): if reception_eth.__instance != None: print(reception_eth.__instance) #reception_eth.__instance = self #raise Exception("This class is a singleton!") else: reception_eth.__instance = self self.initialise() def initialise(self): try:
self.sock, (remhost, remport) = self.srvsock.accept() #print ("connection %s" %sock) # print('ChatServer started on port %s' % self.port) except socket.error as e: print(e) # def start_serial(self): # while True: # print("***********Waiting for the data") # self.message = self.sock.recv(1024).decode('utf-8') # print("Receieved Packet is: "+str(self.message)) # decapsulation.decaptulation(self.message) def send(self, data, destination): print(data) self.sock.send(pickle.dumps(data)) print("Sent")
And I'm calling the send function from many other python files (located in different paths) by creating an object.
Here, This will not throw the error, "Port is already in use" since only one object is created and shared by other files,
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/be550507-7ccd-4a99-bd56-cebfda87f24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d457de3d-4353-47b4-906c-187d616cd9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/be550507-7ccd-4a99-bd56-cebfda87f24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/38035268-5d27-416b-982e-4d1607177000%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/630d439f-d4cc-4989-b4cb-13c2c1d47dc6%40googlegroups.com.