Click here to Skip to main content
15,919,178 members
Home / Discussions / C#
   

C#

 
GeneralRe: App monitoring Pin
Uwe Keim15-Dec-03 7:48
sitebuilderUwe Keim15-Dec-03 7:48 
GeneralFlags Enums Pin
Member 26118815-Dec-03 0:17
Member 26118815-Dec-03 0:17 
GeneralRe: Flags Enums Pin
Heath Stewart15-Dec-03 4:21
protectorHeath Stewart15-Dec-03 4:21 
GeneralRe: Flags Enums Pin
Member 26118815-Dec-03 10:38
Member 26118815-Dec-03 10:38 
GeneralRe: Flags Enums Pin
Eric Gunnerson (msft)15-Dec-03 11:42
Eric Gunnerson (msft)15-Dec-03 11:42 
GeneralRe: Flags Enums Pin
Member 26118815-Dec-03 20:15
Member 26118815-Dec-03 20:15 
GeneralRe: Flags Enums Pin
Eric Gunnerson (msft)16-Dec-03 6:18
Eric Gunnerson (msft)16-Dec-03 6:18 
GeneralHelp me out Pin
Member 76655314-Dec-03 22:25
Member 76655314-Dec-03 22:25 
i have written the code to transfer image file through sockets. Below is the code for client. It just runs and exit nothing happens. Can anybody help?

In this code first i get the file size then the actual file through bytes.

using System;
using System.Net.Sockets;
using System.IO;
using System.Threading;

namespace ImageClient
{
///
/// Summary description for Class1.
///

class Class1
{
bool flag = true;
Socket clientSocket;
AsyncCallback pnfCallback = null;
int fileSize;
byte[] buffer = new byte[1024];
///
/// The main entry point for the application.
///

[STAThread]
static void Main(string[] args)
{
Class1 c = new Class1();
c.clientSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
System.Net.IPEndPoint ipend = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(args[0]),8221);
c.clientSocket.Connect(ipend);
c.WaitForData();

}
public void WaitForData()
{

if(pnfCallback == null)
{

pnfCallback = new AsyncCallback(onDataReceived);
}

IAsyncResult result = clientSocket.BeginReceive(buffer,0,buffer.Length,SocketFlags.None,pnfCallback,null);

}
public void onDataReceived(IAsyncResult result)
{

if(flag)
{
int count = clientSocket.EndReceive(result);
char[] chars = new char[count];
System.Text.Encoding.Default.GetDecoder().GetChars(buffer,0,count,chars,0);
fileSize = int.Parse(new string(chars));
Console.WriteLine("Got the buffer " + fileSize);
Console.ReadLine();
flag=false;
buffer = null;
buffer = new byte[fileSize];
WaitForData();
}
else
{

clientSocket.EndReceive(result);
FileStream fs = new FileStream("c:/def.gif",FileMode.Create);
fs.Write(buffer,0,buffer.Length);
fs.Flush();
fs.Close();
WaitForData();
}

}
}
}
GeneralRe: Help me out Pin
Colin Angus Mackay14-Dec-03 23:05
Colin Angus Mackay14-Dec-03 23:05 
GeneralLoad C# windows applcation from windows service Pin
JeyKey14-Dec-03 22:08
JeyKey14-Dec-03 22:08 
GeneralRe: Load C# windows applcation from windows service Pin
Rampas Tomas15-Dec-03 0:14
Rampas Tomas15-Dec-03 0:14 
GeneralRe: Load C# windows applcation from windows service Pin
JeyKey15-Dec-03 0:27
JeyKey15-Dec-03 0:27 
GeneralGUI Pin
G_ULJEE14-Dec-03 20:59
G_ULJEE14-Dec-03 20:59 
GeneralGDI+ Graphics.DrawRectangle() Pin
krisp14-Dec-03 20:33
krisp14-Dec-03 20:33 
GeneralRe: Drawing rectangles in GDI+ Pin
Arun Reginald Zaheeruddin14-Dec-03 23:28
Arun Reginald Zaheeruddin14-Dec-03 23:28 
GeneralWBEM not WMI Pin
WayneMJ14-Dec-03 18:42
WayneMJ14-Dec-03 18:42 
GeneralGet Folder Attributes Pin
Daniel Negron14-Dec-03 14:57
Daniel Negron14-Dec-03 14:57 
GeneralRe: Get Folder Attributes Pin
Rampas Tomas14-Dec-03 20:57
Rampas Tomas14-Dec-03 20:57 
GeneralHelp Regarding Image Transfer Pin
Ali Gohar14-Dec-03 9:24
sussAli Gohar14-Dec-03 9:24 
GeneralRe: Help Regarding Image Transfer Pin
Heath Stewart15-Dec-03 4:18
protectorHeath Stewart15-Dec-03 4:18 
GeneralHeath - Further External Drag Drop Questions Pin
Tristan Rhodes14-Dec-03 6:42
Tristan Rhodes14-Dec-03 6:42 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Nick Parker14-Dec-03 7:22
protectorNick Parker14-Dec-03 7:22 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes14-Dec-03 12:10
Tristan Rhodes14-Dec-03 12:10 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Heath Stewart15-Dec-03 4:13
protectorHeath Stewart15-Dec-03 4:13 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes15-Dec-03 6:59
Tristan Rhodes15-Dec-03 6:59 

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.