|
If you can already send files over a TCP socket from one computer to another then what's the problem you're having sending a message back over the same channel?
|
|
|
|
|
There pleny of good code examples, look for TCP Queue IO or QIO.
|
|
|
|
|
//This is the server code im using
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class UdpServer
{
public static void Main()
{try
{
int recv;
byte[] data = new byte[1024];
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
Console.WriteLine("Waiting for a client...");
IPEndPoint sender = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
EndPoint tmpRemote = (EndPoint)(sender);
recv = newsock.ReceiveFrom(data, ref tmpRemote);
Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
data = new byte[1024];
string ss = "Welcome to the Server";
data = Encoding.ASCII.GetBytes(ss);
newsock.SendTo(data, data.Length, SocketFlags.None, tmpRemote);
Console.WriteLine("\nSent Acknowledgement");
}
catch (Exception e)
{
Console.WriteLine("Error..... " + e.StackTrace);
}
}
}
//This is the client code which im calling inside a button click event
private void Send_Click(object sender, EventArgs e)
{
Callback();}
private void Callback()
{try
{
byte[] data = new byte[1024];
listBox3.Items.Add("Connecting....");
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
listBox3.Items.Add("Connected");
data = Encoding.ASCII.GetBytes("hello");
listBox3.Items.Add("Transmitting...");
server.SendTo(data, data.Length, SocketFlags.None, ipep);
listBox3.Items.Add("Sent...");
IPEndPoint sender = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
EndPoint tmpRemote = (EndPoint)sender;
listBox3.Items.Add("Message received from {0}:");
listBox3.Items.Add(tmpRemote.ToString());
data = new byte[1024];
int recv = server.ReceiveFrom(data, ref tmpRemote);
listBox3.Items.Add(Encoding.ASCII.GetString(data,0,recv));
catch (Exception e)
{
Console.WriteLine("Error..... " + e.StackTrace);
}
Console.ReadLine();}
When i run this code:
My form design is as follows:
With a button click i list the drives in the system,then with another button click i list the folders in each drive,and then listing the exe files in the folder..I have set a default path say C:\projects\ports.The ports folders in turn contains many folders like 10000,10001 etc..I have copied the exe file obtained when compiling the Server Application to 10000...So with a button click event i will get the exe of the server application which should act as server and i have defined the client in the Form1.cs..Now when i have another button click the message(which i have defined inside the code)should be sent to the exe(i.e.server) opened...Please check my code and tell me whether i should make any changes.
Right now when i run this application the exe(server)window closes when i click "Send" button to send the message to the exe...Please help me with this
|
|
|
|
|
I'm trying to use the PathGradientBrush to create a gradient blend on an elliptical path. I have been able to partialy achieve that by setting the Interpolation property. However, I'm wanting to control how each color blends into the other as with the LinearGradientBrush's Blend property.
For example, say I want two colors to transition from solid blue to solid red instead of gradually fading into one another. Again, this can be achieved with the LinearGradientBrush.
How can this be done with the PathGradientBrush?
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
Gradient != Solid
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I'm guessing by your reply that you don't know that answer.
This is a feature that's implemented in many graphics programs, including PhotoShop. It allows the user to control how soft/hard the blend is between two colors.
Can someone who does know the answer please clue me in?
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
well dude, the answer is simple, you cant have solid colors with GradientBrush.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I'm afraid your probably right. It stinks that the LinearGradientBrush gives you so much more control over blending than the PGB.
If anyone has any further info, please let me know. (that includes you Xmen) Lol
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
Hi,
I have a doubt.If i am using Process.Start() the exe file gets opened.
//Method1
Actually if i am going to run the server from the console,I will use csc /t:exe Server.cs //compile
Server//run
Method2
Previously i defined Server separately and run that file using the console,i defined client in the Form1.cs (which i run using the Start Debugging option).It worked well
Now i have defined client in Form1.cs and try to send message to the server (i.e.exe file).This exe is just opened.Is this exe same as the one obtained by Method1(i.e.exe obtained by using "run" command)?
|
|
|
|
|
Use ProcessStartInfo, and set UseShellExecute to true
Then you can run the process as you where using the console.
Jm
www.menendezpoo.com
|
|
|
|
|
Hi,
I am working with WindowsApplication in VS.NET 2005
I have listed the folders in a drive...for eg:
C:\projects\ports.ports folder in turn contains 10 other folders namely 10000,10001 etc...
I have created a separate application for the client and server to communicate...I have compiled the server application and copied the exe file into folder 10000 and i have included the client as a function in Form1.cs.
In my tool i.e. VS.NET 2005, i have written code to list exe files in a folder.So it gives me Server.exe with a button click.I wanted to run this exe file...I used Start() to do so. The exe file opens when i click start button.
Now i want to send a message from the client to the server(i.e .exe file opened with a button click).Is it possible to do this?
I had a try with this...When i click send button to send message from the client to the exe ,the exe closes...I have not closed the socket in side th code...I dont know why that happens...
Please help me out with this...Thanks for any help in advance.
|
|
|
|
|
Hi all,
I want to find out the name and path if all opened windows which is on task bar. Can anyone help me to get that???
Regards
Lijo
|
|
|
|
|
|
Thanks a lot for ur reply. but from that link i will get only process name.i want all application names which is on task bar.can u plse give me little more clear idea on this???
Regards
Lijo
|
|
|
|
|
Lijo Rajan wrote: i want all application names which is on task bar
Can you explain a bit more ?
Your orignal question was to get all name of opened windows on task bar. The link provides alternate ways to achieve that. The simplest being,
if (p.MainWindowHandle != 0)<br />
{
}<br />
else<br />
{
}
You get all processes using Process.GetProcesses and then loop to check as above. But there are other better means using Window's API which is also mentioned in the post.
|
|
|
|
|
Hi everyone,
I have made a very simple custom control based on the label control.
public class CustomLabel : Label
{
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush sb = new SolidBrush(ForeColor);
e.Graphics.DrawString(Text, Font, sb, Margin.Left, Margin.Top, StringFormat.GenericTypographic);
}
}
Now I have made a form which has one 'CustomLabel' and one 'Label' with exactly the same font.
When the form loads they paint in identical sizes.
If I changed the fonts of both controls like this (scale them by 110%)
label1.Font = new Font(label1.Font.FontFamily,label1.Font.Size * 1.1F,label1.Font.Style);
label2.Font = new Font(label2.Font.FontFamily,label2.Font.Size * 1.1F,label2.Font.Style);
then they begin painting differently. Can anyone help me figure out why even though the two labels
have identical font sizes they draw differently?
Matt
|
|
|
|
|
Is the CustomLabel's font scaling at all? By the way, it's important to call the Dispose() method after using a Pen or Brush.
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
Yeah both fonts are scaling, and if i print the current font size to a message box they
are always the same. It appears as though the normal label is always slightly bigger then
the custom label.
|
|
|
|
|
Have a google on "gdi v gdi+". You'll get lots of hits, some of it is quite interesting.
What I think might be the problem is that behind the scenes the built in rendering uses GDI, whilst, because you're doing it yourself, your custom label is using GDI+.
Hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
anyone knows about auto scrolling a text box. eg:using a for loop i add values upto 100 to text box,but it only displays upto 10,means even though the scroll is set , i have to scroll down to see the values, what i want is to automatically scroll while values are adding to text box.
|
|
|
|
|
use ListBox and change the SelectedIndex/SelectedValue property every time you add some record
|
|
|
|
|
Hi, call the following in the event where u want auto scroll...
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
For example create one textbox n one button in a form and call the above in the button_click event which adds sum text as well as scrolls the textbox..
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + " Hi this is a test message";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
////textBox1.Refresh();
}
I think u got the answer for ur question...
Regards
Mahesh
modified on Tuesday, March 3, 2009 2:23 AM
|
|
|
|
|
hi,
I have a question about RE.
Lets say I have this string:
<option value="\"108|comment|11f42da7\"">Text</option>
I get the "Text" by using this RE:
MatchCollection m = Regex.Matches(wynik,@"\"">\s*(.+?)\s*");
I use MatchCollection beacuse I do it on a bigger file but for the ease of writing ths post I'm just an example of one line.
Then on my collection I do a foreach and each Text is set as an Item Label in a dropDown list.
But in the m regex I would also like to get the "comment" so then in my foreach loop I would be also able to assign it to the items Tag lets say.
How can I achive this?
|
|
|
|
|
I recommend using an XmlDocument for working with XML.
|
|
|
|
|
but it's not a xml document and XmlDocument in that case sometimes doesn't do its job good so thats why I want to use reg. ex.
|
|
|
|