kieth biasillo

kieth biasillo

  • NA
  • 10
  • 1.3k

Client Server implementation questions

Jul 17 2014 12:19 AM
I am working with Visual Studio 2013 express.  I am new to networking and simply trying to get a very simple client server application to work between 2 machines.  For the record, the application works.   I have been able to prove this code works perfectly when run on the same machine.  I believe this is a problem with the implementation of the client app.  
 
i execute the server and its waiting for the connection.  I then go to the client machine and execute that app.... only to get the following error.
 
Deployment and application do not have matching security zones.  Below is the code for both console apps, followed by a couple of questions to help me understand more about what to expect...
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
namespace ClientServerApp1
{
public class serv
{
public static void Main()
{
   try
   {
      IPAddress ipAd = IPAddress.Parse("192.xxx.1.85");
      // use local m/c IP address, and
      // use the same in the client
      /* Initializes the Listener */
      TcpListener myList = new TcpListener(ipAd, 8001);
      /* Start Listeneting at the specified port */
      myList.Start();
      Console.WriteLine("The server is running at port 8001...");
      Console.WriteLine("The local End point is :" +
      myList.LocalEndpoint);
      Console.WriteLine("Waiting for a connection.....");
      Socket s = myList.AcceptSocket();
      Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
      byte[] b = new byte[100];
      int k = s.Receive(b);
      Console.WriteLine("Recieved...");
      for (int i = 0; i < k; i++)
      Console.Write(Convert.ToChar(b[i]));
      ASCIIEncoding asen = new ASCIIEncoding();
      s.Send(asen.GetBytes("The string was recieved by the server."));
      Console.WriteLine("\nSent Acknowledgement");
      /* clean up */
      s.Close();
      myList.Stop();
   }
catch (Exception e)
{
Console.WriteLine("Error..... " + e.StackTrace);
}
}
}
}
 
 
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client
{
public class clnt
{
public static void Main()
{
      try
      {
         TcpClient tcpclnt = new TcpClient();
         Console.WriteLine("Connecting.....");
         tcpclnt.Connect("192.xxx.1.85", 8001);
         // use the ipaddress as in the server program
         Console.WriteLine("Connected");
         Console.Write("Enter the string to be transmitted : ");
         String str = Console.ReadLine();
         Stream stm = tcpclnt.GetStream();
         ASCIIEncoding asen = new ASCIIEncoding();
         byte[] ba = asen.GetBytes(str);
         Console.WriteLine("Transmitting.....");
         stm.Write(ba, 0, ba.Length);
         byte[] bb = new byte[100];
         int k = stm.Read(bb, 0, 100);
         for (int i = 0; i < k; i++)
         Console.Write(Convert.ToChar(bb[i]));
         tcpclnt.Close();
         }
         catch (Exception e)
         {
         Console.WriteLine("Error..... " + e.StackTrace);
         }
}
}
}
 
So, this app doesn't use the windows installer, it uses the ClickOnce install mechanism.  
 
First question would be, can I reasonably expect that given the correct IP address that this application should execute with little other configuration? 
 
Secondly, when I do ipconfig at the command line, it gives me one IP address, yet when I go to whatsmyip dot com, it gives me a different one.  should this make any difference?
 i see a lot of things on the net about IE options and settings for zones, does that apply here because of the TCP/IP aspect of the application?
 
if anyone can help me get this working that would be great. if anyone can point me in a good direction on this that would be good too... just really not sure at this point where to go to solve this issue...  just have no clue as to whether this is IE options, firewall, or installer related issue.  Not even sure if I am asking the right questions at this point.  Any and ALL info is appreciated.