jambeard lewistrix

Greenhorn
+ Follow
since Aug 16, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jambeard lewistrix

I've just started using random access files and need to know what i'm doing wrong.

I've made a test program (just to learn how to work with them) but it dosn't work properlly.

The first part of the program reads in names entered by the user and should work like this:

read in name from user
write to file
repeat until user exits
then add '.' to the end of the file

Then the second reads in the values like this:

read in name
display name
repeat this until '.' char found

The first part of the program definately works. The names get entered and stored in the file and the '.' char gets added to the end of the file.

The second part of the program does not work. If I only enter 1 name in the first program then the second program works, but if I enter more than 1 name then it loops forever outputting null as the name.

This is my code for reading in the names:

Ignore the empty catch statements as this was just a quick test. Also, there's an int called nameNumber in there which is just a number assigned to the name when it is entered in program 1.

Can anyone see what i've done worng?

Cheers,

J
16 years ago
I've just started using random access files and need to know what i'm doing wrong.

I've made a test program (just to learn how to work with them) but it dosn't work properlly.

The first part of the program reads in names entered by the user and should work like this:

read in name from user
write to file
repeat until user exits
then add '.' to the end of the file

Then the second reads in the values like this:

read in name
display name
repeat this until '.' char found

The first part of the program definately works. The names get entered and stored in the file and the '.' char gets added to the end of the file.

The second part of the program does not work. If I only enter 1 name in the first program then the second program works, but if I enter more than 1 name then it loops forever outputting null as the name.

This is my code for reading in the names:

Ignore the empty catch statements as this was just a quick test. Also, there's an int called nameNumber in there which is just a number assigned to the name when it is entered in program 1.

Can anyone see what i've done worng?

Cheers,

J
16 years ago
i need to use a file to save info about reservations. if someone makes a reservation I would add the following info to the file:

reservationNumber, flightNumber, numberOfSeats

now, i'm going to be searching this file a lot and reading info about various reservations. I'm also going to be deleting entries from it based on the reservationNumber (ie, cancel reservation 001 would mean search through file for reservation 001 then delete that line).

What sort of file should I use for this? Does anyone have any code to get me started?

J
16 years ago
I'm becoming quite interested in Global Positioning Systems and was wondering if anyone could tell me a little about the software involved. I'm guessing that in order to make some GPS software you'd have to build a GPS receiver from scratch and program the chip set yourself. Does anyone know of any open source projects along these lines that aren't too advnaced?

Thanks

J
16 years ago
The below code is supposed to work like this; if a client connects, start a new thread, repeat forever (ie, do this everytime a client connects).



Does this do what I think it's supposed to do? At the moment I can't test it properly, all I need to know is: when a client connects and the server starts a new thread will this then continue to wait for connections from other clients (and start new threads when they do connect) or will it wait until the thread has stopped running then wait for another client to connect?

J
I have an idea for my bsc soft eng dissertation but need some help figuring out if it's realistic or not.

Basically it involves something which I have no idea about, the technology which allows you to send a text from your mobile phone to a program (sort of like a server) on a computer. For example, in the UK on BBC Radio 1 you can send a text message to the number 81199 and it will be recieved by a program on the computer infront of the radio presenter. Anyone know anything about this?

My idea involves programming something like a server that would receive these text messages and then do various things depending on the contents of the message.

Does anyone know anything about this stuff? Anywhere where I could try and get some libraries of code that would help me develop something like this?

Thanks

J
16 years ago
Can a server socket send messages like a normal Socket?

At the moment I have a client (of type Socket) which can send / receive messages by writing to / reading from a stream.

I have a server which, when a client connects, starts a new thread which then deals with communication to / from that client.

I want the server to be able to send urgent messages to ALL clients that are currently logged on but have no idea how to do this! Any suggestions?

J
I have a java file which is written in the following format:



Basically I want a boolean value which can be updated by both classes in the file and I don't know how.

The boolean is a flag which, if false will terminate a loop in both myClass and myThread.

J
16 years ago
I have a txt file which stores timetable data in this format:

flightnumber, departuredate, departuretime, avaliableseats

so, at the moment the file looks like this:

001, 01.01.05, 09.00, 10

I need to read in this data and then display it. At the moment my code to do this looks like this:



It all compiles etc but wont read in the values. Also, if I wanted to change one of the values in the file (like avaliableSeats ) how would I do this without updating the whole file (ie, just update the one value as opposed to the whole file).

J
16 years ago
Is there any other info you can give me on datagrams?

I'm supposed to make a client and server program for travel agents. The client is supposed to be able to log on and off from the server (all using datagrams) but from what i uderstand you can't really do that with datagrams because they're a bit random.

I can send / recieve packets but REALLY don't understand how to do anything else with them. Also, after i've recieved a packet, how do I turn the data from a stream of bytes back into a string?
I do indent my code it's just that when I cut and pasted the code from something it all went a bit wrong! sorry
16 years ago
This is the first time i've tried to make a program which requires the use of threads and i'm STUCK!

I have a server and a client. When the client connects to the server, it should start a thread to handle communication with the client.

My problem is that i've tried to do this but the thread dosn't run properly. It starts then stops then starts again for a little longer then stops etc.

I don't know how else to explain it. It would probebly be best if you looked at my code so here's a link to it https://coderanch.com/t/377591/java/java/Network-assignment-HELP-NEEDED

Any help would be greatly apreciated!

Thanks

James.
Firstly if anyone knows any texts / sites which have a lot of info on datagrams could you please tell me!

Ok, I have an assignment which requires me to make a server that can handle multiple clients (and make the clients) using datagram sockets / packets.

One of the things it asks me to do is; when a client connects to the server, the server needs to record the clients name and IP address.

I have NO idea how to do this, I can send packets with datagrams and simple things like that but have no idea how to do this.

Could someone PLEASE help!!

If you want to take a look at the code I have so far go to

https://coderanch.com/t/377591/java/java/Network-assignment-HELP-NEEDED

Thanks

James
Hi, I have an assignment due in a couple of weeks and really need some help with it. I have started it allready and all the code I have written is bellow. I'm very new to java and without the help of my lecturer's am finding this assignment quite hard so ANY help would be apreciated.

This is the assignment:

The assignment is about delivering an on-line (airline JavaJet) booking system. The customer should be able to request a departures time table (2 planes leave per day), make reservations, cancel reservations (only the client who has made the reservation), buy tickets, enquire about free places on a flight.

The system will make use of datagram Sockets technology and will consist of a server and multiple clients. You are to implement a simple information server and several client objects. You need not worry about producing a graphical user interface. (If you do it will be worth extra marks).

The functionality of the Client is that it should

Be able to connect to the server and register its IP address as a valid user along with the name of the user in order to join the service.

Be able to remove the user from the service (e.g. when disconnecting to execute log-off command).

Be able to send a message to the server specifying the information required: - request departures time table per day (2 planes leave per day), - make reservation, cancel reservation, buy tickets, enquire about free places on a flight.

Be able to asynchronously receive and display messages from the information server that a plane has just became fully booked. The second urgent message is that a fully booked plane has just had a cancellation and now has seats available (when somebody else cancels the booking). This requirement can only be properly achieved through use of multithreading.

The functionality of the Server is that it should

Keep a record (in some form) of all on-line registered participants and their addresses.

To be able to accept new participant registrations and add them to the active participants list.

To be able to accept requests from client to remove itself from its records (log-off only from the computer it has registered first).
To read the pre-prepared airline time table from a text file consisting of multiple lines with the following format:
JavaJet <flight Number> <day.month.year> <hh.mm> <total number of seats> < reserved seats> <seats available>

To receive messages and perform the actions required (book, un-book, sell tickets, send timetable information to the cleint.
To handle multiple client connections concurrently.
Maintain correctly the list of seats available in the booking system.

At the moment my code dosn't really work. When I connect to the server it starts a thread and then instantly ends it, then the second time it starts it, runs it for one iteration and then ends it, then starts it, runs it for 2 iterations etc. I can't figure out why.

I'm unsure of how to read the timetable from a file and the thing I am most clueless about is how to asynchronously receive and display messages from server to clients.

I also don't understand how to register the client's IP / name with the server and then store it.

Any other general info and help on datagrams and java would REALLY be appreciated. I'm not asking anyone to do this for me!! Just need a little help.

This is the code I have so far. I've only been working on this for about a day.

This is what I have so far for the server:

This is what I have so far for the client:

This is what I have so far for my thread:

Thanks a lot,

J.
16 years ago