Skip to main content

JXTA Sockets - as simple as possible

5 replies [Last post]
phantasmo
Offline
Joined: 2007-03-09

No matter how much I read on this subject, I can't seem to understand it...
How do I create that dreaded PipeAdvertisment I need in order to create a JxtaServerSocket?? I know this is a basic thing, but.... I'm trying to make a prog that would allow peers to send something to each other through streams, and as I understand, if I use sockets, it will resemble using standard java sockets, more or less... but although I've read the guide and some more stuff I've found on the net, I can't seem to even get the basics of JXTA, mainly due to the fact I don't understand what advertisments are and how are they created :(
so, before I finally decide to give up jxta, I thought asking a live person might help me understand jxtaSockets...

In case it is not much of problem (and I seriously doubt that), I would greatly appreciate a sample code that demonstrates using jxtaSockets for communication, as simple as possible... but still, what I need the most is an explanation on advertisments that I can hopefully understand, so I can finally try to write a code on my own...

I must say, I do feel a bit dumb for asking such a desperate question considering I have developed in java for 2 years now... but for some reason I find it hard to accept this (at least for me) new concept in programming...

anyhow, you have my thanks in advance

good day to you all

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
phantasmo
Offline
Joined: 2007-03-09

I've just downloaded jxta 2.5 beta and tryed to run the socket example I've found... but the client won't connect, no matter what I do... Could it be due to the fact I'm running both client and server from the same machine?? Is there something that should be configured.. or anything?? I'm getting thoroughly frustrated...

anyway... here the code I tried to run on 2.5:

[url=http://platform.jxta.org/source/browse/platform/binding/java/tutorials/socket/]code[/url]

tra
Offline
Joined: 2003-06-16

> I've just downloaded jxta 2.5 beta and tryed to run
> the socket example I've found... but the client won't
> connect, no matter what I do... Could it be due to
> the fact I'm running both client and server from the
> same machine??
No this should work. You may want to just enable multicast
or have one of your peers acts as a local Rendezvous

B.

> Is there something that should be
> configured.. or anything?? I'm getting thoroughly
> frustrated...
>
> anyway... here the code I tried to run on 2.5:
>
> [url=http://platform.jxta.org/source/browse/platform/b
> inding/java/tutorials/socket/]code[/url]

phantasmo
Offline
Joined: 2007-03-09

> No this should work. You may want to just enable
> multicast
> or have one of your peers acts as a local Rendezvous
>
>
> B.
>

Ummm... how do I do that? Does it require any advanced coding or is it a simple matter of clicking something in the configurator?
Yes, I am aware how lame I sound... but I simply can not find my way through...

thanks for the reply tra :)

stheotok
Offline
Joined: 2007-03-12

Hi there,

you don't sound lame at all to me :-) I'm supposed to be a relatively experienced programmer (well, not in JXTA or even JAVA for that matter, but still...) and I've been struggling with the same issues for some time now. I think my problem is that multicast is not really enabled in my setup, as tra also suggested to you above. All I do is keep that "Multicast" box checked in the configurator user interface, but apparently that's not all it takes.

If you make some progress please post something here, I'll do the same.

Good luck,
Steph.

phantasmo
Offline
Joined: 2007-03-09

Heh, glad to know I'm not the only one in the world not able to run an example code ;)
ANyway, here's what I'm doing and getting in detail (I'm posting this because I've managed to get at least 5 different errors by running the project in a different fashion):

I have a separate NetBeans 5.5 project with SocketServer (from the example) as the main class, and every jar from the 2.5 beta1 lib imported separately, except the jxta.jar which I have unpacked and imported as a folder (since I was getting some wierd error otherwise). The other project (same config) has SocketClient as it's main class. Both projects contain both SocketServer and SocketClient.
I deleted all the files jxta created and using jxta shell (2.4.1 shell) I recretated the configs... This time I checked 'act as a rendezvous' and made sure 'multicast' was also selected... I tried to click 'enable incoming connections' under HTTP, but that doesn't seem to work... Peername was set to 'aaa' and when I was first prompted for name/password I entered aaa/aaaaaaaa...
So, after running the project with a server socket, I get this:

Starting ServerSocket
Waiting for connection
socket created
Waiting for connection
sending/receivig xxxxxx bites

and after running client, I get:

Connecrting to server
run #1
sending/receiving xxxx bites
null pointer exception (something about the pipe)

But, here's the sweet part: this only happens if I'm OFFline!! If I'm ONline, I only get:

Starting ServerSocket
Waiting for connection

and

Connecrting to server
run #1
socket time out

... also, I have no idea where to put the config file/folder (.jxta) that o created using the shell... I tried coping it everywhere but it doesn't seem to have any effect... I even tried deleting it and running the code, and it worked just fine... but when I tried doing the very same thing yesterday (using .jxta that was created in NetBeans priject dir when i first initialized jxta) it said it misses a resource...

So, to sum it all up:

1 - Where should I place the jxta configs folder (.jxta) so that my NetBeans apps recognise it?
2 - Is clicking 'act as rendezvous' enough to make my peer act as a rendezvous??
3 - How do i make different instances use different configs??

To the person who actually reads this: THANK YOU!!!