Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User sstoica's Avatar
    Join Date
    Mar 2008
    Posts
    25
    Hello,

    Here is my n00b question for the day. I have 2 libraries like this:

    lowLevelLib.py

    Code:
    from socket import *
    
    def connectUdp(host, port):
        """connectUdp(host,port)
    
        Create an UDP socket and connect to host and port. Return the
        socket and 1/0 if connection was succesfull.
        """
    	try:
    		udpsocket = socket(AF_INET, SOCK_DGRAM)
    		udpsocket.connect( (host, port) )
    		#udpsock.setblocking(0)
    
    	except Exception, ex:
    		#do something
                    udpsocket.close()
                    udpsocket = None
    		return None, 0
    	
            return udpsocket, 1
    highLevelLib.py

    Code:
    import lowLevelLib.py
    
    class server():
    	
    	self.udpScoket = None
    	self.udpState = "closed"
    """ 
    	__init__ + other methods 
    """
        def openUdp(self):
            
             self.udpSocket, connectOK = lowLevelLib.connectUdp(self.connection.host(), self.connection.udpPort())
    	if connectOK:
                self.udpState == "connected"
            #else:
                #self.udpSocket = None
                #self.udpState = "closed"
         
        def closeUdp(self):
    	if udpState == "connected":
    		udpSocket.close()
    		udpSocket = None
    Ok, now if the connection is succesfull (the socket is created and connects to the host) i will pass the socket that i created to my highLevelLib. Can i be sure that after i use highLevelLib.closeUdp() the socket is destroyed for good? I am pretty sure it is, i mean i free the phone's memory, but i want a second opinion. I don't know how to check this in symbian.

    Thanks
    Last edited by sstoica; 2008-04-18 at 17:14.

  2. #2
    Regular Contributor miohtama's Avatar
    Join Date
    Jan 2004
    Location
    Helsinki
    Posts
    376
    Quote Originally Posted by sstoica View Post
    Hello,

    Ok, now if the connection is succesfull (the socket is created and connects to the host) i will pass the socket that i created to my highLevelLib. Can i be sure that after i use highLevelLib.closeUdp() the socket is destroyed for good? I am pretty sure it is, i mean i free the phone's memory, but i want a second opinion. I don't know how to check this in symbian.
    In theory, yes. There has been some reported problems with the current socket implementation of PyS60 with closing and such. The best way to find out is to test this, right?
    Mikko Ohtamaa

    http://mfabrik.com
    http://blog.mfabrik.com

  3. #3
    Registered User sstoica's Avatar
    Join Date
    Mar 2008
    Posts
    25
    it seems to work ^^ thanks miohtama for your reply

Similar Threads

  1. Question concerning socket communication
    By neil.young in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2008-02-12, 22:34
  2. question about variables
    By gemilib in forum Symbian C++
    Replies: 9
    Last Post: 2007-10-30, 11:01
  3. fullscreen camera viewfinder pyS60
    By amerkhan in forum Python
    Replies: 2
    Last Post: 2007-08-09, 14:06
  4. problem in persistant socket connection
    By poms4symbian in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-03, 13:23
  5. socket server application using Series 60 SDK
    By irohit in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-09-16, 05:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved