I can specify the question, so you can request me easily...<br>The int should be an integer of 32 bit fixed. This is total packet size. The string should contain XML.<br>In this example the string is taken from keyboard, so for example.
<br>Thanks all for your helps...<br><br><div><span class="gmail_quote">2006/1/24, Sbaush <<a href="mailto:sbaush@gmail.com">sbaush@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all, i have a python udp client/server.<br>I would send a packed like this: |int|string| . How can i do it with tih client?<br>Another question: buf is the total packet size?<br>





<pre><span style="color: rgb(255, 0, 255);">from</span> socket <span style="color: rgb(255, 0, 255);">import</span> <span style="color: rgb(255, 0, 255);">*</span>

<span style="color: rgb(128, 128, 128);"><i># Set the socket parameters</i></span>
host <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">"<a href="http://192.168.11.49" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">192.168.11.49</a>"
</span>
port <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(0, 0, 255);">21567</span>
buf <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(0, 0, 255);">1024</span>
addr <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(255, 0, 255);">(</span>host,port<span style="color: rgb(255, 0, 255);">)</span>

<span style="color: rgb(128, 128, 128);"><i># Create socket</i></span>
UDPSock <span style="color: rgb(255, 0, 255);">=</span> socket<span style="color: rgb(255, 0, 255);">(</span>AF_INET,SOCK_DGRAM<span style="color: rgb(255, 0, 255);">)</span>

def_msg <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">"===Enter message to send to server==="</span><span style="color: rgb(255, 0, 255);">;</span>
<b>print</b> <span style="color: rgb(221, 0, 0);">"\n"</span>,def_msg<br><br><span style="color: rgb(128, 128, 128);"><i># Send messages</i></span>
<b>while</b> <span style="color: rgb(255, 0, 255);">(</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(255, 0, 255);">):</span>
        data <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(128, 0, 0);">raw_input</span><span style="color: rgb(255, 0, 255);">(</span><span style="color: rgb(221, 0, 0);">'>> '</span><span style="color: rgb(255, 0, 255);">

)</span>
        <b>if</b> <b>not</b> data<span style="color: rgb(255, 0, 255);">:</span>
                <b>break</b>
        <b>else</b><span style="color: rgb(255, 0, 255);">:</span>
                <b>if</b><span style="color: rgb(255, 0, 255);">(</span>UDPSock.sendto<span style="color: rgb(255, 0, 255);">(</span>data,addr<span style="color: rgb(255, 0, 255);">)):</span>
                        <b>print</b> <span style="color: rgb(221, 0, 0);">"Sending message '"</span>,data,<span style="color: rgb(221, 0, 0);">"'.....<done>"</span>

<span style="color: rgb(128, 128, 128);"><i># Close socket</i></span>
UDPSock.close<span style="color: rgb(255, 0, 255);">()</span></pre><br><br clear="all"><br>-- <br><span class="sg">Sbaush

</span></blockquote></div><br><br clear="all"><br>-- <br>Sbaush