• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to send messages from server to client initiatively?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my application will be used in that environment:
the server has a real ip,
but the client may be in a LAN , the client doesn't have a real ip ,it connects to WAN
through NAT.

just like a chat software, or other p2p software,
the server has to send messages to client initiatively and continuously.
(that means the server will send messages .At the same time ,the client will accept those messages like a server.)

if i use socket to write my code , i just need use send ,
then, although the client in a LAN ,i can connect to it ,and send messages initiatively.

but now ,i can't get the client 's ip and port in ICE.
how to do when i have to send messages to a client which is in a LAN and don't have a real ip ?
i need the server sends messages initiatively.
is there any example which can let me study?

thanks in advance
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
didn't quite get your question. here is my 2 cents.

ip is the network layer. without the ip address, i don't think you can send send anything.

let us assume you have the network layer, if you want to server to send something to client, you can send the message using UDP first from the "server" to "client"
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can't have the server connect to the client, for the reasons you gave. But once the client is connected, there is nothing to stop messages from being sent in either direction at any time. You just have to program the client to be ready to receive messages from the server.`
 
suvankar bose
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TO PAUL

when the client get connected it connects with a global ip which is actually the ip which is natted.

so when we use
DatagramSocket send method .
send(new DatagramPacket(buffer,pos,INTERNET_ADDERSS_OF_THE_CLIENT,CLIENT_PORT))

I think we will not get the INTERNET_ADDRESS_OF_THE_CLIENT
because the client is using the natted ip.

if you have any code that do bi directional massage please post

it will be great help Paul



 
suvankar bose
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

luri ron wrote:didn't quite get your question. here is my 2 cents.

ip is the network layer. without the ip address, i don't think you can send send anything.

let us assume you have the network layer, if you want to server to send something to client, you can send the message using UDP first from the "server" to "client"



who said i want to connect to any computer that does not have ip.
client have a local ip . but to connect to WAN it uses a common natted ip.
in actual many internet provider gives you a natted ip to connect to net .
so when you are connected to net if you see your ip address by an ipconfig. you may not get a ip that is global.
most of the time you get a natted ip
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. i hope i don't get you hit the wall again.

this all depend how your router is set up to map your natted address to ip address for outside public network. it can be static, dynamic, overloading, and others.

first of all, one question, in your application, how does the server know that your client is up to know that it needs to send something to your client?

if you simply use tcp/ip socket connect to the server, then follow the protocol defined. everything should just fall together.
 
knowledge is the difference between drudgery and strategic action -- tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic