For a school assignment, I have to create a Client/Server application in Java that uses sockets to communicate. All communications have to be in XML format. Now, the difficulty of the assignment is that we have never done Client/Server programing in Java up until now, so I'm kinda lost. I managed to set up pretty much everything except for the XML communication and I'm lost. I use the JDOM library to create a small XML document in my server, and I attempt to send it through a stream to the client. Now thing is, I'm not sure what I need to send. I have a Document object that I guess that I could send, but it's not really XML, it's an object so it can't be read by a say, a python client does it ? Do I actually have to create a file, send the file, delete the file just to send my xml to the client ? Can anyone give me a hint I'm really lost here. Would it be easier in another library ?
The Big Programming Thread - Page 402
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
SpiZe
Canada3640 Posts
For a school assignment, I have to create a Client/Server application in Java that uses sockets to communicate. All communications have to be in XML format. Now, the difficulty of the assignment is that we have never done Client/Server programing in Java up until now, so I'm kinda lost. I managed to set up pretty much everything except for the XML communication and I'm lost. I use the JDOM library to create a small XML document in my server, and I attempt to send it through a stream to the client. Now thing is, I'm not sure what I need to send. I have a Document object that I guess that I could send, but it's not really XML, it's an object so it can't be read by a say, a python client does it ? Do I actually have to create a file, send the file, delete the file just to send my xml to the client ? Can anyone give me a hint I'm really lost here. Would it be easier in another library ? | ||
|
DeltaX
United States287 Posts
| ||
|
Manit0u
Poland17490 Posts
On November 25 2013 05:14 3FFA wrote: Another thing I would like to know is what exactly are the differences between the various C's? Is there specific purposes/situations each is better for? I think this wasn't explained well enough earlier on since everyone just started talking about what they program in and even I posted a video that only explained how different platforms utilise various C-family languages. I think it's a valid question that many people ask themselves and I can start explaining it for posteriority here. Since I'm not familiar with all of C's offspring I'll only cover what I know. Basically, the main difference here will be the level of abstraction and what libraries those languages use for the most part. Abstraction-wise it's more or less like that: C < C++ < C# This means that you will have to put in more work into accomplishing the same thing when using language that has lower abstraction level. It has both its drawbacks and benefits. While you can do something really easy in C# it won't give you the level of control and optimization that C++ offers (and I won't even mention C with manual memory management) as it's closer to the inner-workings of a system and hardware. Let's take a closer look at the differences between C++ and C# now (since C is too far removed from this layer of abstraction to really talk about it in the same way). On the Windows platform they can both be used for the same things for the most part but C# with higher abstraction is easier to do stuff using .NET libraries. C++ on the other hand is king when it comes to developing using the DirectX and has much greater support for Win32 and COM API stuff than C#. The choice of preferred language is up to the person using it and what you want to do with it. If you want to build huge databases and an application that spends more time "thinking" than "doing" then you might want to consider F#, if you want to create a simple Metro app then why not use HTML5/CSS/JS? Perhaps others can add their 2 cents regarding other C offspring (Java, Objective C, JavaScript). | ||
|
obesechicken13
United States10467 Posts
On November 30 2013 01:45 SpiZe wrote: Hi people, For a school assignment, I have to create a Client/Server application in Java that uses sockets to communicate. All communications have to be in XML format. Now, the difficulty of the assignment is that we have never done Client/Server programing in Java up until now, so I'm kinda lost. I managed to set up pretty much everything except for the XML communication and I'm lost. I use the JDOM library to create a small XML document in my server, and I attempt to send it through a stream to the client. Now thing is, I'm not sure what I need to send. I have a Document object that I guess that I could send, but it's not really XML, it's an object so it can't be read by a say, a python client does it ? Do I actually have to create a file, send the file, delete the file just to send my xml to the client ? Can anyone give me a hint I'm really lost here. Would it be easier in another library ? Java has some great libraries for communicating with SQL. I did that for a course earlier, but I haven't tried doing client server connections with XML. Sorry I can't be much help. I don't see why you can't read the file and send the contents of the file by stream though. Unrelated to the above, does anyone know if there is any point to using dateTime vs dateTimeOffset? DateTimeOffset has everything DateTime does and DateTimeOffset also supports timezones. | ||
|
spinesheath
Germany8679 Posts
On November 30 2013 17:54 obesechicken13 wrote: Unrelated to the above, does anyone know if there is any point to using dateTime vs dateTimeOffset? DateTimeOffset has everything DateTime does and DateTimeOffset also supports timezones. It would always be nice to also mention the language. If it's C#, I think I remember there being some pretty concrete advice on MSDN on this subject. | ||
|
obesechicken13
United States10467 Posts
On November 30 2013 18:04 spinesheath wrote: It would always be nice to also mention the language. If it's C#, I think I remember there being some pretty concrete advice on MSDN on this subject. It is C#. DateTimeOffset http://msdn.microsoft.com/en-us/library/bb630289.aspx DateTime http://msdn.microsoft.com/en-us/library/bb677335.aspx#feedback | ||
|
Tobberoth
Sweden6375 Posts
On November 30 2013 18:05 obesechicken13 wrote: It is C#. dateTimeOffset http://msdn.microsoft.com/en-us/library/bb630289.aspx DateTime http://msdn.microsoft.com/en-us/library/bb677335.aspx#feedback This is not C#, it's T-SQL ![]() As for reason to use one or the other, datetime2 requires at most 8 bytes, at minimum 6 bytes. datetimeoffset requires 10 bytes always. I guess that's a reason to use datetime2, but really, whoever sits on a database so big that this would matter, yet cares about this difference in bytes, is doing something wrong. | ||
|
obesechicken13
United States10467 Posts
Fk, yes, it is T-SQL. My bad! | ||
|
soiii
Germany266 Posts
I have no idea what is happening here ![]() Edit: figured it out, that is actually a function declaration ^^. I am quite new to C++. | ||
|
Arnstein
Norway3381 Posts
| ||
|
Warri
Germany3208 Posts
On November 30 2013 22:36 Arnstein wrote: I'm learning ARM assembly these days, any idea of something easy to make? Do all the sorts! | ||
|
Manit0u
Poland17490 Posts
On November 30 2013 20:33 soiii wrote: Can somebody give me a hint what is happening when I declare a struct variable like so (C++): "MyStruct *struct_name();" ? I have no idea what is happening here ![]() Edit: figured it out, that is actually a function declaration ^^. I am quite new to C++. This is strange though. You create structs like so:
And then if you want to do stuff with it you declare functions like that:
Or I'm messing something here? | ||
|
Rollin
Australia1552 Posts
On December 01 2013 00:10 Manit0u wrote: + Show Spoiler + On November 30 2013 20:33 soiii wrote: Can somebody give me a hint what is happening when I declare a struct variable like so (C++): "MyStruct *struct_name();" ? I have no idea what is happening here ![]() Edit: figured it out, that is actually a function declaration ^^. I am quite new to C++. This is strange though. You create structs like so: struct MyStruct{ };And then if you want to do stuff with it you declare functions like that: struct MyStruct* MyFunction(args) Or I'm messing something here? C++ doesn't require the struct keyword to set the type (outside of initialisation ofc) regardless of whether or not you use a typedef in the intitalisation. C (ansi at least) requires the struct keyword if you don't typedef the struct. ie: typedef struct{Works in ANSI C. struct{Also works in ANSI C. struct{Only works in C++. Thus his function prototype was valid =). | ||
|
WarSame
Canada1950 Posts
For my own personal curiosity, and for a future(legal) business idea I'm looking into creating a botnet by myself. Could someone please point me to a good basic guide for creating a botnet? It doesn't need much info on bypassing security because I'm assuming for now that it will be allowed through. Thank you. | ||
|
Zocat
Germany2229 Posts
Have them connect to another server (IRC is often used) to command them. | ||
|
Warri
Germany3208 Posts
I have this endless loop:
At the start of the program pause is set to true and is not changed in the class which contains the loop. It is only changed in another class, which contains a gui. And heres the weird part: pause gets set to false correctly, but the loop still doesnt run. However, if i add a System.out.println("foo"); inside the loop, it works. So my assumption is, java falsely "optimizes", aka removes, the loop, because the condition is never changed to true inside the class. How can i prevent that without adding dummy commands? | ||
|
Nyxisto
Germany6287 Posts
So the task was to write a method that reads hex numbers from a file, converts them, and prints them out through the console. Problem is, we're not allowed to use Buffered Readers or something similar, we're forced to use a "StdIn" class that we were given, which has a bunch of methods to read from the Standard Input, and we should redirect the Standard Input to read from the file instead from the console. So i looked it up and the Syntax seems to be something like "java classname.java < filename.txt" But if i run the program and type that into the console, it just echoes "java classname.java < filename.txt" instead of actually printing out the content of the file. Would be glad if anyone has an idea what's wrong here. | ||
|
Manit0u
Poland17490 Posts
On December 01 2013 04:42 Warri wrote: Woa java is driving me nuts today. I have this endless loop:
At the start of the program pause is set to true and is not changed in the class which contains the loop. It is only changed in another class, which contains a gui. And heres the weird part: pause gets set to false correctly, but the loop still doesnt run. However, if i add a System.out.println("foo"); inside the loop, it works. So my assumption is, java falsely "optimizes", aka removes, the loop, because the condition is never changed to true inside the class. How can i prevent that without adding dummy commands? Can you make it more like this? Class A
Class B
I think it would be even better if you had 3 classes. 2 that actually do stuff and have all the data and another one acting as an interface for the other two to communicate. This way you can easily shuffle stuff around and change things later. | ||
|
obesechicken13
United States10467 Posts
http://msdn.microsoft.com/en-us/library/bb384267(v=vs.110).aspx | ||
|
Warri
Germany3208 Posts
On December 01 2013 05:00 Manit0u wrote: Can you make it more like this? Class A
Class B
I think it would be even better if you had 3 classes. 2 that actually do stuff and have all the data and another one acting as an interface for the other two to communicate. This way you can easily shuffle stuff around and change things later. Hm i dont understand what the parameter is for in queryPause, if pause is a member of Class B? I tried this: Class A:
Class B:
This also doesnt work. But again, if i change the getPause() method to
it starts working... i dont get it ![]() | ||
| ||

