You Are Here:

Community: Developer Discussion Boards

#1 Old sockets - 2009-01-26, 23:59

Join Date: Nov 2008
Posts: 139
widetech1
Offline
Regular Contributor
hi,

How can I share an object of type socket between two threads?

thanks
Reply With Quote

#2 Old Re: sockets - 2009-01-27, 00:20

Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Online
Forum Nokia Champion
Quote:
Originally Posted by widetech1 View Post
hi,

How can I share an object of type socket between two threads?

thanks
I am not sure if the following is what you want but ... here it goes:

Code:
from threading import Thread
from socket import *
from time import sleep

# worker task
def tsk(s):
    print "socket", s
    i = 5
    while i > 0:
        i -= 1
        sleep(1)
        

s = socket(AF_INET,SOCK_STREAM)
# put other socket stuff here, like connection
# ...

# creating threads
t1 = Thread(target=tsk,args=(s,))
t2 = Thread(target=tsk,args=(s,))

t1.start()
t2.start()

# waiting thread finalization
t1.join()
t2.join()
Remove print from tasks if you want to run in pys60 console. You can do the same using classes as well.


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote

#3 Old Re: sockets - 2009-01-27, 01:08

Join Date: Nov 2008
Posts: 139
widetech1
Offline
Regular Contributor
hi marcelobarrosalmeida,

But python S60 supports threading module?


thanks
Reply With Quote

#4 Old Re: sockets - 2009-01-27, 01:23

Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Online
Forum Nokia Champion
Quote:
Originally Posted by widetech1 View Post
hi marcelobarrosalmeida,

But python S60 supports threading module?


thanks
Just latest version, widetech1. If you may update, try to download PythonForS60 1.9.1. More: Queues and semaphores available as well !

Marcelo


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
help~~~about the CMdaAudioInputStream Dragon_L Symbian Media (Graphics & Sounds) 14 2008-11-05 07:11
Using sockets in the fullduplex example niranjancsc Symbian Media (Graphics & Sounds) 1 2007-03-22 13:52
How to send HBufC8 over sockets? niranjancsc Symbian Networking & Messaging 16 2007-02-18 08:16
Questions about sockets, I need help. _fox Symbian Networking & Messaging 0 2004-06-10 11:29
Where to find application that uses sockets? doctordwarf Mobile Java General 1 2004-03-10 16:45

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia