Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

help with socket programming ???

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing a project on GPRS communication

my project requires sending a string of data from PC to a mobile

the MOBILE service provider i use uses a WAP GATEWAY so i cannot connect to it

because the IP address of the mobile is hidden behind the gateway


so i changed it to that the mobile will connect to the PC
i am able to establish the connection and the string of data is going to PC
but the response i.e " data recieved"
should be sent but how do i send the repsone

please tell me because i do not know the IP ADDRESS OF THE MOBILE ???

please help me with code if you can because i am new to J2ME or please explain me the logic atleast
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Presumably you've created a ServerSocket on the PC, right? You call accept(), and when the mobile connects you get a Socket. The Socket is a two-way connection endpoint: you can read from it as well as write to it. Likewise, the Socket that the mobile is sending on, it should also be able to read from. You don't close the connection until everybody is through.

You use Socket.getInputStream() to get a stream you read from; you use Socket.getOutputStream() to get one that you write to.
 
vp pan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply
will the GATEWAY part will be handled automatically by the JVM

is this what you mean to say

that if the mobile establishes

client.java ( on the mobile)
------------------

all imports


--------------
server.java (on the PC)
---------------

 
Your buns are mine! But you can have this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!