Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Sep 21st, 2007, 10:35 PM   #1
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Smile PHP to Python?

Is there anyone that is able to convert this small php snippet
 fputs($sock,"\\status\\"); $gotfinal=False; $data="";
 socket_set_timeout($sock,0,200000);
 $starttime=Time();
 while(!($gotfinal==True||feof($sock))) {
  if(($buf=fgetc($sock))==FALSE) usleep(100);
  $data.=$buf;
  if(strpos($data,"final\\")!=False) $gotfinal=True;
  if((Time() - $starttime)>2) { 
    $gotfinal=True;
   }
 }
 fclose($sock);
 $chunks=split('[\]',$data);

to Python??
I've got

    global chunks
    s.send("\\status\\")
    final = False
    while(final != True):
        data = s.recv(1024)
        if (len(data) <= 0): sleep(1); data = data, s.recvfrom(1024)
        if(data.find("final\\") != False): final = True
    chunks = data.split('\\')

But as you'll notice tis is not really a good match !!
Thanks for anyone that is able to help!
It would be greatly appriciated!! :banana:
__________________
while me is alive:
	make(life,simple)
SaturN is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginers Python Tutorial Beegie_B Python 15 Jul 28th, 2006 12:43 PM
[tutorial] Python for programming beginners coldDeath Python 30 Dec 14th, 2005 12:35 PM
Convert Python script to C++ code clanotheduck Python 17 Sep 25th, 2005 9:55 AM
Advanced Python Tricks Arevos Python 19 Sep 24th, 2005 8:39 AM
Python - A Programmers Introduction coldDeath Python 17 Aug 19th, 2005 1:41 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC