Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My projects works fine using local host loop back 127.0.0.1 on my computer only.
but how to use this on two different computers? and how to do the configuration settings for these computers.And how to connect these computers with each other,i means is there necessary to have a router or the ethernet cable?

i have followed the tutorial from here: Instant Messaging Application - Part 1 - YouTube[^]

Here is the client side configuration

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
        <client>
            <endpoint address="net.tcp://127.0.0.1:9000/ChattingService"
                binding="netTcpBinding" bindingConfiguration="" contract="ChattingInterfaces.IChattingService"
                name="ChattingServiceEndPoint" kind="" endpointConfiguration="" />
        </client>
    </system.serviceModel>
</configuration>






Here is the server side configuration

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    
    <system.serviceModel>
        <services>
            <service name="ChattingServer.ChattingService">
                <endpoint address="net.tcp://127.0.0.1:9000/ChattingService"
                    binding="netTcpBinding" bindingConfiguration="" name="ChattingServiceEndPoint"
                    contract="ChattingInterfaces.IChattingService" />
            </service>
        </services>
    </system.serviceModel>
</configuration>


What I have tried:

I tried to connect two laptops using ethernet cable.And gave them specific addess

For server setup laptop's ipv4 setting i have done following configuration:
Ip address: 192.168.0.1
subnet mask: 255.255.255.0
default gateway: 192.168.0.1

primary dns: blank
secondary dns :blank


On clients laptop i did following configuration on ipv4:
Ip address: 192.168.0.100
subnet mask: 255.255.255.0
default gateway: 192.168.0.1

primary dns: 192.168.0.1
secondary dns :blank
Posted
Updated 16-Nov-17 11:24am

1 solution

Quote:
,i means is there necessary to have a router or the ethernet cable?


Im not being sarcastic but I can't tell if this is a real question or a question made out of frustration. But in short, computers have to be connected in some way shape or form in order to communicate with each other. If you are doing this in 2 different physical locations then of course you'll need a router and either wifi or hard wired connections.

Given you didn't post code and I don't have access to your computer. Assuming the applications work then this is pretty straight forward.

You need to change your clients configuration XML to not point at itself. As you mentioned, 127.0.0.1 is the localhost/loop back IP address. If your chat server app has been moved to another computer then hopefully it would be obvious that it is no longer at the IP of 127.0.0.1.

Assuming 192.168.0.1 is the server IP ad address, you config file needs to look like this on the client machine
XML
<endpoint address="net.tcp://192.168.0.1:9000/ChattingService"
                binding="netTcpBinding" bindingConfiguration="" contract="ChattingInterfaces.IChattingService"
                name="ChattingServiceEndPoint" kind="" endpointConfiguration="" />


It sounds as though you had done this but I think the other point where you are getting stuck is at the server firewall. Port 9000 isn't typically a conventional port so you will more than likely need to open this port on the servers firewall, whether this is at the router or windows firewall, you'll need to allow connections on port 9000 for tcp/udp.
 
Share this answer
 
Comments
Member 13496560 16-Nov-17 17:29pm    
Thanks for your reply David...
I get that point to put 192.168.0.1 on server config xml, when it moved to another laptop.I have tried for many times,But which IP should i use on client app config?And i am trying to connect two laptops using Ethernet cable. And i disabled all my windows firewall as well as installed antivirus on both laptops as well as i also open the connection for port 9000 tcp/udp as well.But still i can not make a connection between server side and client side.

Here is the server computer ipv4 settings
Ip address: 192.168.0.102
Subnet mask: 255.255.255.0
default gateway: 192.168.0.102

primary: empty
secondry dns: empty

Here is config code for server
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    
    <system.serviceModel>
        <services>
            <service name="ChattingServer.ChattingService">
                <endpoint address="net.tcp://192.168.0.102:9000/ChattingService"
                    binding="netTcpBinding" bindingConfiguration="" name="ChattingServiceEndPoint"
                    contract="ChattingInterfaces.IChattingService" />
            </service>
        </services>
    </system.serviceModel>
</configuration>


And here is for client,where i used 192.168.0.103,which is the static ip of another laptop,where client app is running.

Here is the server computer ipv4 settings
Ip address: 192.168.0.103
Subnet mask: 255.255.255.0
default gateway: 192.168.0.102
primary dns:192.168.0.102
secondry dns:empty
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
        <client>
            <endpoint address="net.tcp://192.168.0.103:9000/ChattingService"
                binding="netTcpBinding" bindingConfiguration="" contract="ChattingInterfaces.IChattingService"
                name="ChattingServiceEndPoint" kind="" endpointConfiguration="" />
        </client>
    </system.serviceModel>
</configuration> 

Furthermore i am attaching my full project here https://www.dropbox.com/s/apnq18x19vlgac2/ChattingApplication.rar
David_Wimbley 16-Nov-17 17:47pm    
Haven't looked at your code but i think your issues is in your client config. Also, you may be making this harder than it actually is.

Your computer and server have to know each others "names" (ip addres) in order to talk to each other. Your client config is being told the person they are talking to is itself. Your client computers IP address is 192.168.0.103 and your setting the endpoint of the chatting service, for how your wpf app needs to communicate to the server as itself which would explain it not working as your client computer is not running the chatting server app as well.

Your client config, based on what you are describing,needs to swap out 192.168.0.103:9000 in the endpoint address for 192.168.0.102/9000 as .102 is the server IP which is where your client needs to point/direct its traffic towards.

As i mentioned before, you are/will also have the issue of ports being closed on the server since 9000 isn't really a conventional port. So you'll need to make sure your firewall on the server is accepting traffic on port 9000.


David_Wimbley 16-Nov-17 17:49pm    
Just a note, eyeballed your config files in your dropbox upload. Your config files both point to 127.0.0.1 in the server/client config files. Make sure you update those accordingly.
Member 13496560 17-Nov-17 16:03pm    
Okey Dear David,i totally got your instructions.And thank u very much for brief explanation.Which made my concept totally clear but here i am asking you three questions.Having their answers i will understand the whole process...I will be very thank full to u man.I needs the certain information only.I spent a lot time for searching the answers.But still having some misunderstanding.

1-First tell me how to allow server to listen on port 9000?

i have done the following steps described on < http://www.tomshardware.com/faq/id-3114787/open-firewall-ports-windows.html >

2- Can you please describe physical connectivity of two laptops?
i mean can u guide me step by step for how to connect two laptops with each other.For testing on both situations within router and without router?

3-How to do Ipv4 configuration on both laptops.Should i use the static IP for server side config file? step by step guide,And can i use the server computer name instead for putting server ip?

Thank you
David_Wimbley 17-Nov-17 17:37pm    
1) Your link you provided for firewall port opening on windows firewall is correct. Where it asks for your port number you just enter 9000 on the server for inbound connections.

2) I do not mean to sound as though I am insulting your intelligence but how much networking do you know? Are you really asking me how computers communicate/need to communicate or is there an underlying question that isn't being conveyed?

Reason I ask those questions is connectivity between 2 computers is pretty basic and i think you are making this problem harder than it is.

What is it that you are doing that is requiring a router?

So if you are doing this with 2 laptops in your home, assuming you have wifi...there is nothing you need to do in regards to connecting two computers together to allow them to talk to each other.

Even if the server is off site, say, in a data cetner. As long as you have that servers IP address, the externally facing IP address, you don't need to worry about what your router is doing (within reason, given what you are attempting to do, you shouldn't have to worry about your router).

3) If your laptops are within the same building and are on your wifi in your house for example, all you need to do is use the IP v4 address.

For example, my desktop address is
IPv4 Address. . . . . . . . . . . : 192.168.1.94

So if my chat application had the server on my desktop, then the laptop that i install the chat client on would point to my IP address of 192.168.1.94.

You can use the servers hostname/computer name but for your purposes, I'd suggest going with IP address to not complicate things.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900