hi every body

i'm a new user in this site , and this term I am doing graduation project ..


So , I wanna ask some questions in programming ..


first one :
how to connect between 2 computers via wireless ??

second :
If the connectivity between the computers are done .. I will have two types of computer .. first is receiver , the other one is sender .....
if I have 2 computers had be sent at the same time ( ex. sends calls ) ..
How to arrange the receiver of these orders coming to him ..?
( using C# )..


thanx ..

MiNi

Wireless or not, you have to use TCP or UDP so you first connect computers to network and then send data.

thnax VIeditorlover 4 replay

I'll use wireless..
but how 2 use TCP or UDP .. ?

:)

okay .. connection is done . !!

but how I send data from one to other .. and How to arrange the receiver of these orders coming to him ..?

:|

Using sockets.

how .. ?

( soory Sorry for the inconvenience
But I need it very much much )

:(

soory I did not understand

What is it that you are trying to send, is it just a quick "Hey I can connect to you" or is it more complex?
Are you trying to do this as a console program, or windows forms? Each have their own benefits.
Are you trying to do this over the internet, or on a Local Area Network? cause well, internet wise, will take time, and LAN is relatively easy.
Do you have any programming experience? if not. this may take sometime for you to get the hang of.

either way, you need to learn some socket programming. The easier way to do this would be in synchronous manner.
you can view the synchronous client sample here.
and the synchronous server sample here

the async samples are on the page right below on the left hand side, however if you've never done socket programming, I would stick to the sync examples.

If you still don't get it, reply with what you need, I think i might be able to do something for you. commented, so that you can follow allong.

first , I do not know how thanking you ,, your written are assure me very much ..
so .. I wish you success in your life ..


I'll answer on your questions :

What is it that you are trying to send, is it just a quick "Hey I can connect to you" or is it more complex?
i'll send some commands to move robot .. or some commands to tell other computer ( i wanna robot ) .. and so on ..

Are you trying to do this as a console program, or windows forms? Each have their own benefits.
of course : win forms .

Are you trying to do this over the internet, or on a Local Area Network?
via LAN

Do you have any programming experience? if not. this may take sometime for you to get the hang of.
ya .. of course

either way, you need to learn some socket programming. The easier way to do this would be in synchronous manner.
ya i think that .. but unfortunately i have not any info about "socket programming"..


( Initial notions:
There are 4 users .. Each user is send order ( call a robot) ..
Administrator is receiving orders .. and he is put it in a List ..

After that .. According to orders .. he sends the robot to ( all users they had sent in-order ) ..

After that .. If the implementation of the first call .. Request is deleted from the list .. And if the call is canceled also ..)


I hope that my idea is clear..

thnaxxx again ..

Good luck .

I still don't quite understand what type of program you require cause i don't understand what you are trying to do. However I help you with a quick client connect code using sync sockets.

This client code only connects to a server and then disconnects.
we will add more code once I get better details of how you are trying to make this work.


first Add these to your using statements.

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

Alright lets first being by creating a method to use.

public void ConnectToServer()
{

}

within that module lets do some stuff.
create a socket. set the IPaddress to connect to. and set the Socket to Blocking mode.

Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Blocking = true; // sets the socket in blocking mode.
IPEndPoint server = new IPEndPoint(IPAddress.Parse("127.0.0.1"),8080);

alright the socket is now setup.
Lets try and connect to the Server.

add this code to your ConnectToServer module

try
{
    // Connect to the server.
    clientSocket.Connect(server);

    // Disconnect the Socket.
    clientSocket.Disconnect(true);

    // Close the Socket.
    clientSocket.Close();

    // Display Connected Message.
    MessageBox.Show("You connected to the Server","Information");
}
catch (SocketException se)
{
    MessageBox.Show(se.ToString());
}

The try statement tries and connects to the server, if it does not connect to the server, then it throws an exception which displays a message box with the exception.

if the client connects to the server a message box is displayed that states that the client connected to the central server.

The ConnectToServer method should look like this.

public void ConnectToServer()
{
    Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    clientSocket.Blocking = true; // sets the socket into blocking mode.

    // Change the loopback address to the address of the server.
    IPEndPoint server = new IPEndPoint(IPAddress.Parse("127.0.0.1"),8080);
    try
    {
        // Connect to the server.
        clientSocket.Connect(server);

        // Disconnect the Socket.
        clientSocket.Disconnect(true);

        // Close the Socket.
        clientSocket.Close();

        // Display Connected Message.
        MessageBox.Show("You connected to the Server","Information");
    }
    catch (SocketException se)
    {
        MessageBox.Show(se.ToString());
    }
}

you now have a really cheap, really simple client. However when you call this from your Connect button, you should call it like this.

Thread connectToServer = new Thread(new ThreadStart(ConnectToServer));
connectToServer.Start();

Alright I had the tutorial set up for the Server, then my computer crashed.
However I'm going to give you the code for the server. If you have any questions please ask.
Both the Server and Client could be run on the same machine. But each would have to be compiled then run.

public void StartServer()
{
    Thread startServer = new Thread(new ThreadStart(Server));
    startServer.Start();
}

Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
private void Server()
{
    // Lets Create an endpoint for the listener to bind to.
    IPEndPoint server = new IPEndPoint(IPAddress.Any, 8080);
    
    // alright lets try and start the listener.
    try
    {
        listener.Blocking = true; // set the listener into a blocking state.
        listener.Bind(server); // Bind the server's IP to the Listener. 
        listener.Listen(1); // Listen for one connection.

        // If the Socket Gets connected to.
        while (listener.Connected)
        {
            // Disconnect the Socket from the client.
            listener.Disconnect(true);

            // Close the Listener Socket.
            listener.Close();

            // Restart the Server, to wait for another connection.
            Server();
            MessageBox.Show("A Client Connected to the Server", "Connection - Succesfull");
        }
    }
    catch (SocketException se)
    {
        // The Socket could not start.
        MessageBox.Show(se.ToString());
    }
}

I will create a video, on how to do this, and a video on how to use it. It's more of a video tutorial, hopefully it will help more than text tutorials. wait about 1 - 2 hours for a video tutorial.

Sorry for the last code, I forgot to add something to keep it listening, and i need to remove something because it only applies to async connections.

public void StartServer()
{
    Thread startServer = new Thread(new ThreadStart(Server));
    startServer.Start();
}

Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
private void Server()
{
    // Lets Create an endpoint for the listener to bind to.
    IPEndPoint server = new IPEndPoint(IPAddress.Any, 8080);
    
    // alright lets try and start the listener.
    try
    {
        listener.Blocking = true; // set the listener into a blocking state.
        listener.Bind(server); // Bind the server's IP to the Listener. 
        listener.Listen(1); // Listen for one connection.

        // If the Socket Gets connected to.
private void StartServer()
{
    listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    listener.Blocking = true;
    IPEndPoint server = new IPEndPoint(IPAddress.Any, 8080);
    try
    {
        listener.Bind(server);
        listener.Listen(1);
        while (true)
        {
            workSocket = listener.Accept(); // added this.
            if (workSocket.Connected)
            {
                workSocket.Close();
                MessageBox.Show("A client connected to the server!!");
            }
        }
    }
    catch (SocketException se)
    {
        MessageBox.Show(se.ToString());
    }
}

This code repeats constantly, when you try to shutdown the application it will not cause this module is made to run constantly.
At the moment, i have not comeup with a way to stop this from running when trying to stop the application.

Alright finish all the videos, however i'm unable to upload them all tonight, I will do it tommorrow.

Client Socket Tutorial - sorry no sound, it's late here, But i wanted to get this up for you, so that you could go over it. All you have to do is launch the html file and press play. It's about three minutes in length. Hope this helps. Will upload the other 2 videos tommorrow.

^_^

thanx v.much .. :)

plz .. see in praivate msg ..


^_^

Going back to the article above: http://www.daniweb.com/software-development/csharp/threads/184784/how-to-connect-between-2-computers-in-c-
I wonder what environment is required in each machine. I am not as smart as those guys-just some c and quick basic. I just want to know how folks would connect two computers running user written c programs so the programs could communicate over the eithernet. I finally mastered it in quick basic using the serial port. But I am 40 years behind. What is the modern way? Isn't this canned and simple by now?

I followed some of the links and backtracked up the Microsoft website. This stuff looks frightful. I don't want to make a career of this just yet. Maybe next year. I played with Borland turbo c version3 about 20 years old, and chickened out of version 5. I got Ubuntu old 9.2 running on one machine and this one has windows XP. I better settle for some advice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.