Xinetd & python server script. problem to get data from from client



I wrote simple script to test communication:
When i connect via telnet like: "telnet localhost 51423" the server is
working send and receive information. but when i connected to him via
client scrip so client script receive messages from server but server
doesn't receive message from client. In xinetd.conf and servers conf
file "only_from = 0.0.0.0/0" already choosen. What can i do
Here below are my client and server:
Thank you

Server:

#!/usr/bin/env python
# example

import sys
import os

print "Wellcome"
print "please enter the string"
sys.stdout.flush()
line = sys.stdin.readline().strip()
print "You entered %d characters." % len(line)
sys.stdout.flush()

client:

import sys
import string
import os
import time
import socket
import popen2

PORT = 51423
HOST = ""#sys.argv[1]
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
print "Connected from:", sock.getsockname()
print "Connected to:",sock.getpeername()
while 1:
print "waiting"
result = sock.recv(1024)
print result
sock.send('foo')
print "Sent: foo"
if result == 3:
break

Posted On: Monday 5th of November 2012 02:21:30 AM Total Views:  268
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Poor python and/or Zope performance on Sparc

everybody, I'm posting this message because I'm quiet frustrated. We just bought a software from a small software vendor. In the beginning he hosted our application on a small server at his office. I think it was a Fujitsu-Siemens x86 running debian Linux. The performance of the DSL-Line was very poor, so we decided to buy an own machine to host the application ourselves. The application is based on the Zope Application server (2.8.8-final w/ python 2.3.6) along with many other packages like ghostview, postgres, freetype, python imaging lib, etc... I once saw the application running at the office of my software vendor and it was running very well. So I thought that - when the bottleneck of poor DSL performance has disappeared - the software will run as fast as at his office. But I erred. The performance is more than poor. We have a Sun T1000 with 8 cores and 8 GB of RAM. First, I installed Solaris 10 because I know this OS better than Debian Linux. Result: poor Performance. After that I decided to migrate to debian: root@carmanager > uname -a Linux carmanager 2.6.18-5-sparc64-smp #1 SMP Wed Oct 3 04:16:38 UTC 2007 sparc64 GNU/Linux Result: Almost even worse. The application is not scaling at all. Every time you start a request it is hanging around on one cpu and is devouring it at about 90-100% load. The other 31 CPUs which are shown in "mpstat" are bored at 0% load. If anybody needs further information about installed packages, I'll post it here. Any hints are appreciated!
VIEWS ON THIS POST

91

Posted on:

Monday 5th November 2012
View Replies!

bsddb in python 2.5.1

Have a rather big problem with bsddb I can't figure out. I upgraded an Ubuntu machine from 7.05 to 7.10 which upgraded python to 2.5.1 I run a local website that uses bsddb, and suddenly I get a version mismatch error with bsddb and I can't access my database anymore I noticed in the 2.5.1 release notes: - fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments were transposed. - Added support for linking the bsddb module against BerkeleyDB 4.5.x. http://www.python.org/download/releases/2.5.1/NEWS.txt I know that when you upgrade Berkeley DB you're supposed to go through steps solving this problem,but I wasn't expecting an upgrade. I've tried to use different versions bsddb3, 4.4 and 4.5, (instead of bsddb that comes with python 2.5.1) with different versions of Berkeley DB installs (4.5 and 4.4 - built from source into /usr/local). But this isn't working. I can't seem a way to figure out how to recover my data. Please help. : (
VIEWS ON THIS POST

100

Posted on:

Monday 5th November 2012
View Replies!

read part of jpeg file by pure python

, I am wondering whether it's possible to read part (e.g. 1000*1000) of a huge jpeg file (e.g. 30000*30000) and save it to another jpeg file by pure python. I failed to read the whole file and split it, because it would cost 2GB memory. Can anyone help me Any comments would be appreciated.
VIEWS ON THIS POST

151

Posted on:

Monday 5th November 2012
View Replies!

Re: Modul (%) in python not like in C?

"Dotan Cohen" wrote in message news:880dece00709091201n449d4c2k31998a5d426de17d@mail.gmail.com... | FIrst of all, how is the % symbol (as in 70%6=4) called in English | | Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or | the other in error Is this a known gotcha I tried to google the | subject however one cannot google the symbol %.
VIEWS ON THIS POST

93

Posted on:

Monday 5th November 2012
View Replies!

python socket usage

Is it possible to send a data object like a tuple or a list in socket programming If so how It seems with socket module it is only possible to send strings. -- O\tuz Yarmtepe http://www.yarimtepe.com/en
VIEWS ON THIS POST

131

Posted on:

Monday 5th November 2012
View Replies!

Registering a python function in C

Could someone post an example on how to register a python function as a callback in a C function It expects a pointer to PyObject... how do I expose that Basically, the signature of the function is foo(PyObject* obj), where obj is the callback function... It's not exactly extending or embedding, I've looked at those examples but they don't really show how to do this...
VIEWS ON THIS POST

170

Posted on:

Monday 5th November 2012
View Replies!

python2.5 and mysqldb

Hi all, At work we're using python2.3 and I'd like to start getting us moved up to python2.5. We run Centos4 which is the free, open source version of RedHat Enterprise. I've got python2.5 installed on this machine, but am stuck trying to get mysqldb installed and running on this machine. I've tried with easy_install and by building from the tar file and both return a long list of errors from a gcc compile. I'm not sure what to do next to resolve this issue, so if anyone could give me some guidance it would be greatly appreciated.
VIEWS ON THIS POST

159

Posted on:

Monday 5th November 2012
View Replies!

simple spider in python

Hi everybody, i'm new to the forum so: hello everybody (should I say "world") ^_^ I'm trying to do a simple spider in python which: 1) ask google a query 2) parse the data I'm a python newbie so *any* help would be very, very welcommed.
VIEWS ON THIS POST

190

Posted on:

Monday 5th November 2012
View Replies!

How can I use python for file processing

I am trying to use python for file processing. Suppose I have a file like this: I want to build a Hashmap between the line "begin_QOS_statistics" and "end_QOS_statistics" and for each line I want to put the first text as the key of the hash table and the second text as the value. Received RTCP "BYE" on "audio/MPA" subsession (after 89 seconds) Received RTCP "BYE" on "video/MP4V-ES" subsession (after 89 seconds) begin_QOS_statistics server_availability 100 stream_availability 100 subsession video/MP4V-ES num_packets_received 3529 num_packets_lost 0 elapsed_measurement_time 82.302305 kBytes_received_total 3756.422000 measurement_sampling_interval_ms 100 kbits_per_second_min 0.000000 kbits_per_second_ave 365.134075 kbits_per_second_max 2634.760139 packet_loss_percentage_min 0.000000 packet_loss_percentage_ave 0.000000 packet_loss_percentage_max 0.000000 inter_packet_gap_ms_min 2147483.647000 inter_packet_gap_ms_ave 0.000000 inter_packet_gap_ms_max 0.000000 subsession audio/MPA num_packets_received 1414 num_packets_lost 0 elapsed_measurement_time 82.302305 kBytes_received_total 1187.644000 measurement_sampling_interval_ms 100 kbits_per_second_min 0.000000 kbits_per_second_ave 115.442113 kbits_per_second_max 1132.007640 packet_loss_percentage_min 0.000000 packet_loss_percentage_ave 0.000000 packet_loss_percentage_max 0.000000 inter_packet_gap_ms_min 0.022000 inter_packet_gap_ms_ave 52.214517 inter_packet_gap_ms_max 140.955000 end_QOS_statistics
VIEWS ON THIS POST

137

Posted on:

Monday 5th November 2012
View Replies!

Apache cgi and multiple versions of python

I am running OS X and have Python 2.3 installed with the system and have installed 2.5 using the installer available at pythonmac.org. I am running the system install of Apache 1.3 and I am not using mod_python. When Apache 1.3 runs Python cgi scripts, the cgitb output indicates that the verision of python being used is 2.3. I would like it to use Python 2.5. Does anyone have any advice on how to get Apache to use the version of Python I would like it to
VIEWS ON THIS POST

108

Posted on:

Monday 5th November 2012
View Replies!

Re: creating a tar file with python

On Aug 24, 2007, at 11:24 AM, Carsten Haese wrote: > You clearly have no idea who you're talking to. I suggest you > Google for > '"Steve Holden" Python' to get a clue. Good luck finding any more help > here. Even if it were Joe Nobody to whom he was directing those comments, it was *way* out of line. The fact that it was Steve only reinforces the cluelessness of the writer. -- Ed Leafe -- http://leafe.com -- http://dabodev.com
VIEWS ON THIS POST

156

Posted on:

Monday 5th November 2012
View Replies!

porting vc++ project to python?

hi, i have a very large project in visual studio2005->visual c++ in windowsxp. i'd like to port it, or my next project, over to python. is this possible without rewriting all my code are there multiple options to do this my project is so large, that entirely rewriting it is actually no option. regards, m ps i guess, it's an option to transform my current code into one or more python extensions/modules, and then calling them from a python core module
VIEWS ON THIS POST

94

Posted on:

Monday 5th November 2012
View Replies!

Re: Tokenizer for python?

>From your description I think something like PyParsing might be useful to you. http://pyparsing.wikispaces.com/ If not then I guess I m not understanding your question right. Hope this helps Nathan On 21/08/07, Robert Dailey wrote: > > > I am looking for a sort of "tokenizer" for python. I've taken a look at the > tokenize module, but that seems to parse python code from what I read. I > want a tokenizer that works a little like boost::tokenizer, however for > python. Basically I want to be able to pass in an arbitrary string (or line > from readline()) and specify tokens that cause the string to be separated > into parts, much like the regular expression split() method (I think that's > the name of it). Is there anything that already exists that does this, or do > I need to implement it myself with regular expressions > >
VIEWS ON THIS POST

64

Posted on:

Monday 5th November 2012
View Replies!

mmm-mode, python-mode and doctest-mode?

> Anyone testing on xemacs I tried it, and C-c C-c sent xemacs into an > infinite loop (apparantly). It works fine for me in XEmacs 21.4 (patch 17) (i386-debian-linux, Mule). If you could answer a few questions, it might help me track down the problem: - What version of xemacs are you running - What version of doctest-mode are you running (0.4 or 0.5) - Are you using doctest-mode by itself, or in combination with another mode (via mmm-mode) - Does pressing control-g (possibly repeatedly) cause it to become unstuck - Does it always freeze when you hit C-c C-c Or does it depend on the contents of the buffer Does it freeze if you run it in an empty buffer You could try changing the value of doctest-python-command, to see if that helps -- "M-x customize-variable doctest-python-command". Set it to the full path to a Python interpreter.
VIEWS ON THIS POST

90

Posted on:

Monday 5th November 2012
View Replies!

Simple python iteration question

I just started with python, and have a for loop question In c++ (or a number of other languages) I can do this: for (int i=0, j=0; i < i_len, j< j_len; ++i, ++j) {} If I have this in python: l = ['a', 'b', 'c'] I want to get the value and also an iterator: for i,v in len(l), l: print v print i Or something like this without declaring the iterator outside my loop... How do I do this
VIEWS ON THIS POST

105

Posted on:

Monday 5th November 2012
View Replies!

Re: Configuring apache to execute python scripts using mod_python handler

On Aug 13, 5:16 am, joe jacob wrote: > I configured apache to execute python scripts using mod_python > handler. I followed below mentioned steps to configure apache. > > 1. In http.conf I added > > > AddHandler mod_python .py > PythonHandler mptest > PythonDebug On > > > 2. Then I added the line "LoadModule python_module modules/ > mod_python.so" to http.conf. > > Then I tried execute the python script mentioned below from browser. > > from mod_python import apache > def handler(req): > req.content_type = 'text/plain' > req.write(" World!") > return apache.OK > > Then I am getting the following error > > Traceback (most recent call last): > > File "D:\softwares\Python25\Lib\site-packages\mod_python > \importer.py", line 1537, in HandlerDispatch > default=default_handler, arg=req, silent=hlist.silent) > > File "D:\softwares\Python25\Lib\site-packages\mod_python > \importer.py", line 1202, in _process_target > module = import_module(module_name, path=path) > > File "D:\softwares\Python25\Lib\site-packages\mod_python > \importer.py", line 304, in import_module > return __import__(module_name, {}, {}, ['*']) > > ImportError: No module named mptest > > I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5- > Apache2.2. > > I am able to execute python scripts by configuring apache to execute > the cgi scripts. But I want to execute it using mod_python as it is > faster compared to cgi mode. Someone please help me on this issue. 1) In the mod_python tutorial it says: ------- 2.4 Testing .... .... 2. Add the following Apache directives, which can appear in either the main server configuration file, or .htaccess. If you are going to be using the .htaccess file, you will not need the tag below (the directory then becomes the one in which the .htaccess file is located), ***and you will need to make sure the owOverride directive applicable to this directory has at least FileInfo specified. (The default is None, which will not work.)**** AddHandler mod_python .py PythonHandler mptest PythonDebug On -------- Note the last sentence in the directions above. I explain what is needed for that part at the link in (2) below. Also note the directory listed in the opening tag: /some/directory/htdocs/test That specifies a sub directory of htdocs. That's because the htdocs directory has its own tag in httpd.conf, which specifies the things you can to with it. If you look around in httpd.conf, you will see the tag that applies to htdocs. Mine looks like this: .... .... The mod_python Testing tutorial wants you to create your own sub directory in htdocs, so that you can specify your own rules for that directory. You're probably getting errors because you have two tags in your httpd.conf file for the htdocs directory, and the second tag is overwriting the first one. 2) You can see the latter part of this thread for what I did to get mptest.py to work: http://groups.google.com/group/comp....2645ec03370fb2 3) I put any tags I added to httpd.conf below the first tag in http.conf, which is this one: so that the ones lower down in the file will override the previous tags if there is a conflict.
VIEWS ON THIS POST

117

Posted on:

Monday 5th November 2012
View Replies!

re: mmm-mode, python-mode and doctest-mode?

On Tue, 7 Aug 2007, Edward Loper wrote: > [John J Lee] >> Is it possible to get doctest-mode to work with mmm-mode and python-mode >> nicely so that docstrings containing doctests are editable in doctest-mode > > I recently released a new version of doctest-mode [1], and I came across your > email [2] (it was on the first page of google hits for "doctest-mode"). So I > decided to have a go at getting doctest-mode to play nicely with mmm-mode. > The result is available here: > > https://python-mode.svn.sf.net/svnro...octest-mode.el Nice! Works for me so far (emacs 22). I'm also very pleased to see that doctest-mode no longer attempts to auto-fill at the end of long lines -- that was extremely annoying, and the new behaviour is a big improvement. Here's another wish. My next-nearest doctest-mode annoyance: hitting TAB should have similar behaviour to python-mode. So, the first press of the TAB key gets you a sensible guess at the indentation you want. The second and subsequent TAB keypresses cycle through no indentation, '>>>' indentation, and '...' indentation. Ideally this would be made to work in combination with the standard indentation-cycling behaviour in those cases where multiple indentations are allowed within Python code (so, it might be ' ... ', '', ' >>> ', ' ... ',' ... ', ' ... ' as the TAB key is repeatedly pressed). >> `doctest-example' >> >> Used to edit doctest examples in text-editing modes, such as >> `rst-mode' or `text-mode'. Docstring submode regions start with >> optionally indented prompts (>>>) and end with blank lines. Use >> (C-c % C-e) to insert a new doctest-example region. When >> `doctest-execute' (C-c C-c) is called inside a doctest-example >> region, it executes all examples in the buffer. I couldn't immediately see how to get this working in a .doctest file, so haven't tried this yet. Another wish: Even though I don't normally run code from emacs directly, I do think it would be very handy indeed to be able to execute a *single* doctest example from doctest-mode. Don't know what keybinding would be conventional... John
VIEWS ON THIS POST

129

Posted on:

Monday 5th November 2012
View Replies!

How to avoid reverse code engineering of a python executable

Hi guy's, Couple of day's ago I asked for your help on how to create a single file of a python executable. Now I want to proceed a little bit further asking how can I avoid (or at least make it difficult) for some one to extract my code by using reverse code engineer techniques I came on pyobfuscate but I would like more suggestions and guide to achieve the most possible security in this matter.
VIEWS ON THIS POST

211

Posted on:

Monday 5th November 2012
View Replies!

DBUtil with modepython

Hi all I have used DBUtil in mysql databse. when we run to program in dos command ,successfully run but when we run in apache server (locally)with modepython then given error.Pls give me suggation error: No module named DBUtils.PooledDB cp mishra
VIEWS ON THIS POST

121

Posted on:

Monday 5th November 2012
View Replies!

[python-list] pdf read & write

Dear all, How can I read a pdf file and add invisible comment I want to make a script which read a pdf file and add tags inside the file invisibly. Then, I will make a script for managing tags of given pdf files. I know "referencer" can manage tags for pdf file but it seems store tag information to additional file outside pdf file. Any suggestion are welcome. Best, Hyunchul Kim
VIEWS ON THIS POST

214

Posted on:

Monday 5th November 2012
View Replies!