Click here to Skip to main content
15,900,467 members
Home / Discussions / C#
   

C#

 
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik23-Aug-04 8:48
Radoslav Bielik23-Aug-04 8:48 
GeneralRe: Best way to calculate hash Pin
Heath Stewart23-Aug-04 6:30
protectorHeath Stewart23-Aug-04 6:30 
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik23-Aug-04 8:53
Radoslav Bielik23-Aug-04 8:53 
GeneralSorting an Arraylist Pin
malik1022-Aug-04 19:59
malik1022-Aug-04 19:59 
GeneralRe: Sorting an Arraylist Pin
sreejith ss nair22-Aug-04 20:11
sreejith ss nair22-Aug-04 20:11 
Generalproblem implementing special gradient Pin
obby22-Aug-04 19:52
obby22-Aug-04 19:52 
GeneralRe: problem implementing special gradient Pin
leppie22-Aug-04 21:03
leppie22-Aug-04 21:03 
GeneralProblem in HTTP POST Pin
khchan22-Aug-04 18:49
khchan22-Aug-04 18:49 
hi,

my app is constituted by a http client (ppc emulator) and a http server (desktop).

the server accepts multipart POST.

my problem is that, sometimes the server can just receive the http header sent by the client. i dunno it's the problem of my server or client. Confused | :confused:

here is my code segment:
CLIENT:
WebRequest request;
Stream requestStream;

try
{
request = HttpWebRequest.Create(url);
request.ContentType = "multipart/form-data; boundary=" + boundaryString + "\r\n";
request.ContentLength = message.Length;
request.Method = "POST";
request.Timeout = 10000;

requestStream = request.GetRequestStream();
requestStream.Write(message, 0, message.Length);

// Close the Stream object.
requestStream.Close();


// 1. Get the Web Response Object from the request
WebResponse response = request.GetResponse();

// 2. Get the Stream Object from the response
Stream responseStream = response.GetResponseStream();

// 3. Create a stream reader and associate it with the stream object
StreamReader reader = new StreamReader (responseStream);

// 4. read the entire stream
results = reader.ReadToEnd();

reader.Close();
responseStream.Close();
}

catch(WebException webEx)
{
results = "An exception occurred relating to the use of " +
"a web response or request object. The specific exception was:" +
webEx.Message;
}

//Did some type of general exception occur?
catch(Exception ex)
{
results = "A general exception occurred while attempting to " +
"retrieve the requested page." +
ex.Message;
}

SERVER:
private void AcceptCallback(IAsyncResult ar)
{
// Signal the main thread to continue.
allDone.Set();

// Get the socket that handles the client request.
Socket listener = (Socket) ar.AsyncState;
Socket handler = listener.EndAccept(ar);
f1.ShowSystemMessage("\r\nClient Connected!!"
+"\r\n=================="
+"\r\nCLient IP "
+ handler.RemoteEndPoint + "\r\n");

// Create the state object.
StateObject state = new StateObject();
state.workSocket = handler;

handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReadCallback), state);
}

private void ReadCallback(IAsyncResult ar)
{
String content = String.Empty;

// Retrieve the state object and the handler socket
// from the asynchronous state object.
StateObject state = (StateObject) ar.AsyncState;
Socket handler = state.workSocket;

// Read data from the client socket.
int bytesRead = handler.EndReceive(ar);

if (bytesRead > 0)
{
state.sb.Append(Encoding.ASCII.GetString(state.buffer));

f1.ShowSystemMessage(state.sb.ToString());
ProcessRequest(state);

// Check for end-of-file tag. If it is not there, read more data.
content = state.sb.ToString();

// All the data has been read from the client. Display it on the console.
f1.ShowSystemMessage("Read " + content.Length.ToString()
+ " bytes from socket. \r\n Data : " + content );

state.ClearSB();
}//end if
}

thanks Blush | :O
GeneralRe: Problem in HTTP POST Pin
LongRange.Shooter23-Aug-04 7:40
LongRange.Shooter23-Aug-04 7:40 
GeneralWinForms -> Submit (POST) to a web page and get results Pin
theoutlander22-Aug-04 18:36
theoutlander22-Aug-04 18:36 
GeneralRe: WinForms -> Submit (POST) to a web page and get results Pin
Mazdak22-Aug-04 19:30
Mazdak22-Aug-04 19:30 
GeneralProfessional database advice Pin
steve_rm22-Aug-04 18:03
steve_rm22-Aug-04 18:03 
GeneralRe: Professional database advice Pin
Mazdak22-Aug-04 19:18
Mazdak22-Aug-04 19:18 
GeneralRe: Professional database advice Pin
steve_rm23-Aug-04 5:25
steve_rm23-Aug-04 5:25 
GeneralMarshalling struct with array member Pin
rana7422-Aug-04 15:41
rana7422-Aug-04 15:41 
GeneralRe: Marshalling struct with array member Pin
leppie23-Aug-04 3:51
leppie23-Aug-04 3:51 
QuestionHow to export data from datagrid to excel? Pin
tzewei22-Aug-04 14:15
tzewei22-Aug-04 14:15 
AnswerRe: How to export data from datagrid to excel? Pin
Jay Shankar22-Aug-04 16:49
Jay Shankar22-Aug-04 16:49 
GeneralRe: How to export data from datagrid to excel? Pin
tzewei22-Aug-04 20:29
tzewei22-Aug-04 20:29 
GeneralRe: How to export data from datagrid to excel? Pin
tzewei22-Aug-04 22:02
tzewei22-Aug-04 22:02 
GeneralRe: How to export data from datagrid to excel? Pin
Jay Shankar24-Aug-04 0:33
Jay Shankar24-Aug-04 0:33 
GeneralDataColumn question Pin
blankg22-Aug-04 10:14
blankg22-Aug-04 10:14 
GeneralRe: DataColumn question Pin
sreejith ss nair22-Aug-04 18:56
sreejith ss nair22-Aug-04 18:56 
GeneralRe: DataColumn question Pin
blankg22-Aug-04 21:12
blankg22-Aug-04 21:12 
GeneralRe: DataColumn question Pin
sreejith ss nair22-Aug-04 21:37
sreejith ss nair22-Aug-04 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.