473,480 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Socket Hang Problem (Weird)

Hello!
I have a J# socket client that does an HTTP Post. Code pasted below. This
client works fine on my XP and Win 2003 boxes, but on my Win 2000 Server box,
the socket just hangs when it tries to read. No exception nothing just hangs.
Any suggestion?

public static String httpPost(String url, String payload, String
ContentType)throws Exception, System.Exception
{
WebResponse result = null;
StreamReader sr = null;

try
{
WebRequest req = WebRequest.Create(url);
req.set_Method("POST");
//req.set_ContentType("application/x-www-form-urlencoded");
req.set_ContentType(ContentType);

ubyte[] SomeBytes = null;

if (payload != null)
{

//SomeBytes = HttpUtility.UrlEncodeToBytes(payload);
SomeBytes = Encoding.get_UTF8().GetBytes(payload);
req.set_ContentLength(SomeBytes.length);
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.length);

newStream.Close();
}
else
{
req.set_ContentLength(0);
}

result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
sr = new StreamReader(ReceiveStream, encode);
System.Text.StringBuilder strb = new StringBuilder();
String str;
while ((str = sr.ReadLine()) != null)
{
strb.Append(str).Append( "\r\n");
}
return System.Web.HttpUtility.UrlDecode(strb.ToString(), encode);
}
catch(Exception e)
{
throw e;
}
catch (System.Exception se)
{
throw se;
}
finally
{
if(sr != null)
sr.Close();

if (result != null)
result.Close();
}
}//getPage
Jul 21 '05 #1
0 1278

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
8483
by: anuradha.k.r | last post by:
hi, i am writing a socket program in python,both client side and server side.I've written the client side which is working perfectly fine(checked it against server program written in C).but as for...
1
1552
by: Koen Vossen | last post by:
Hi, I came across some exceptional behaviour (pun intended) when I was programming a small chat server. I've simplified my original code to the following minimal version that still exhibits the...
1
3792
by: martinnitram | last post by:
Dear all, following are some piece of my code (mainly create a socket connection to server and loop to receive data): # function to create and return socket def connect(): server_config =...
1
2954
by: Dave | last post by:
Hi, i am writing a c# application that use direct show to play mpg file but when i declere a socket in my c# application i just cant play the file enymore, It seems that the problem is because...
2
3617
by: zb011 message | last post by:
Hi all, I have coded an outbound Socket program in C on a solaris box that sends out data and receives an acknowledgement for it. However, have faced this problem of a "HANG" state, whereby...
2
1148
by: Lespaul36 | last post by:
I have tried many things. I still have not found anything that seems to work. Here is the portions of my code that deal with the listening socket maybe you have a better idea? The form still...
0
277
by: Tejaswi | last post by:
Hello! I have a J# socket client that does an HTTP Post. Code pasted below. This client works fine on my XP and Win 2003 boxes, but on my Win 2000 Server box, the socket just hangs when it tries...
0
4228
by: chsalvia | last post by:
On Linux (Ubuntu) I'm trying to figure out how to avoid recv() calls that hang forever by using using a non-blocking socket along with the select() function. This seems to be the standard way to...
3
3598
by: Joe Blauth | last post by:
Hi all, I am currently working on a small application that sends messages from a client to a server and receives messages in return. Basically the functionality is made with sockets which is...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.