473,463 Members | 1,512 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 1274

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

Similar topics

11
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
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
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
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
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
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
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
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.