ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Do you have any suggestions for what I should do or do I pretty much have to start from scratch. I looked for a c# to c++ converter and could not find one. What would be your advice?
Well, if you have to have networking and/or a gui, and you have
to have it work on multiple os's with the same code, then I would
say to use Java.
Learning java isn't the easiest thing to do, but you'll get a lot more
help with it in this forum than you will with C#
Despite all the not so great things about java, the libraries are
pretty much portable between windows and linux.
HOWEVER, I've never done networking in java on win/lin before,
so you might want to ask someone who's done it before to make
it sure it'll work before you go and learn a new language.
Well, since I am not going to be able to use the c# code that I have wrote in linux I was wondering if you could take a look at this vb6 code and offer any insight on the translation that I will need to make in order to begin codeing in c or c++. This is the same server that needs to run in linux only currently it is vb6. If you prefer I ould give you the c# code but for now ill give you the vb6 since I know that this code will compile and is correct. Any specific code translation that you can give me as well as any other code will be a huge help. thanks alot
Option Explicit
Dim sServerMsg As String
Private Sub Form_Load()
'The port number is arbitrary.
' it's best to use a fairly high number
' because the low numbers are used for
' standard services: 21 for FTP, 23 for telnet,
' 80 for HTTP etc...
Winsock1(0).LocalPort = 10119
'start listening for a connection
Winsock1(0).Listen
'Define the message and show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
'the winsock control has to be in a closed state
' before it can do anything else. (like accept a connection)
Winsock1(Index).Close
'Let the winsock close
DoEvents
'accept the connection request
Winsock1(Index).Accept requestID
'Define the message and display it in the list box
sServerMsg = "Serving client!"
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_Close(Index As Integer)
'When the other end has closed the connection,
' close server end too
Winsock1(Index).Close
'to continue listening for another connection
Winsock1(Index).Listen
'show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim strTemp As String
'Dim strTemp2 As String
Dim a As Integer
'This event fires when the process on the other end of the connection(i.e the client)
'sends data
'retreive data from socket
Winsock1(Index).GetData strTemp
'Winsock1(Index).GetData strTemp2
'The following code separates each part of the string based on the comma
'that is present in the incoming string and parses it out into its
'respective textbox
a = InStr(strTemp, ",")
txtcoilid.Text = Left(strTemp, a - 1)
'after the first parse you must refine the string as everthing after the comma and
'repeat the process throughout the entire string
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtwidth.Text = Left(strTemp, a - 1)
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtlinespeed.Text = Left(strTemp, a - 1)
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtexitcoillength.Text = Left(strTemp, a - 1)
Do you think that you would be able to help me with the java at all? If not I appreciate any help you can give me with the c/c++. I appreciate you taking your time to help.
Well, I can help you with c, c++, java, as well as a few other
languages. You have decide which you need. It sounds like
you need java since portability is your biggest concern.
Yes, basically I need to pass four values from my vb6 client to a linux server. I currently have the slax live cd distro but I cant seem to understand the "one line text editor". I downloaded knoppix which was referred to me by mnay other people and planned to used that. which do you think would be best. Can you write java on knoppix? You have more expertise in this type of thing than I do.......if java is the way to go....lets go with java. Let me know whatever you need to help and im going to take a look at the link you gave me. Basically, I just need to translate those four functions and what ever else is needed for java
I downloaded knoppix which was referred to me by mnay other people and planned to used that. which do you think would be best. Can you write java on knoppix?
Don't know about knoppix but I've heard it's easier than slax. I just
suggested slax because I use slackware. Yes, I can write java on
anything (to a certain extent). Yeah, probably use knoppix if slax is
giving you troubles.
No offense, but I think you have an oversimplified view of this,
full blown client server apps don't just get translated by changing
a few functions.
Is the linux server youre sending this data to already set up? If so,
it might just be easier to do this in a web app with php.
Since I don't really know vb, can you tell me what the goal of this
project is?
I am a co-op college student working on a project for a steel company. I wrote a client in vb6 that calculates various different values for the stell as it is being rolled(i.e. coil id, gauge, speed, width, etc.) We have put a network camera up on the rolling line so that the vice president and managers can monitor the steel as it is being rolled from a pc. On our network you are able to watch the video feed of the steel. The current video has the time and date scripted into the video feed. I need to write a server in linux that will pass the four values that my boss is interested in into linux(because that is what the camera operates in). Once the program(server) recieves the 4 values......I will upload the program to the camera and parse out the values giving them their respective names. Is this something that you can help with. As you see, I just need to recieve the necessary 4 value which are on a timer to be sennt and updated every second. The server end will not do any sending of information, just recieving. Let me know if you have any code that I can start playing around with and where I should start as well as if you need any more info.
I have a hunch it would be easier to do this with php, since you
could use apache (probably already installed) and avoid having
to write your own server.
Quote:
I will upload the program to the camera and parse out the values giving them their respective names.
What exactly are you doing here, saving the values in a database, or
something else?
The values need to be updated to the second on the video feed and then may be saved to a data base.....im not sure what they will decide next. I am getting confused now.. So I should not do it in java?........I know nothing about php and have no idea what apache is either. I burnt knoppix to a cd and went to the console and have the following java code wrote but have not compiled it yet.
import java.net.*;
import java.io.*;
public class Server {
public static void main(String[] ar) {
int port = 10119; // just a random port. make sure you enter something between 1025 and 65535.
try {
ServerSocket ss = new ServerSocket(port); // create a server socket and bind it to the above port number.
System.out.println("Waiting for a client...");
Socket socket = ss.accept(); // make the server listen for a connection, and let you know when it gets one.
System.out.println("Got a client ... !");
System.out.println();
// Get the input and output streams of the socket, so that you can receive and send data to the client.
InputStream sin = socket.getInputStream();
OutputStream sout = socket.getOutputStream();
// Just converting them to different streams, so that string handling becomes easier.
DataInputStream in = new DataInputStream(sin);
DataOutputStream out = new DataOutputStream(sout);
String line = null;
while(true) {
line = in.readUTF(); // wait for the client to send a line of text.
System.out.println("The client just sent me this line : " + line);
System.out.println("Waiting for the next line...");
System.out.println();
}
} catch(Exception x) {
x.printStackTrace();
}
}
}
If possible, can you clarify what you think would be the best approach and maybe give me some code to test to see if I can at least get a connection or something to work with.
The values will be passed to to the server program which will then be stored on the cameras memory. From there you can telenet the camera and tell it to run the program----parse out the values----and script it to the video stream.
PHP looks alot easier but I dont see how I am going to get my values to pass to the server?
Will sockets be used?
this will have to be a program that can be stored on the camera for it to parse out the values. How do I pass the values to the server using PHP. I have no idea how I am going to write this...I know nothing about php or apache...lol.....will you be able to give me the code I need to do this and the steps that need to be taken?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.