LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-27-2005, 11:55 AM   #16
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30

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?
 
Old 05-27-2005, 12:02 PM   #17
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
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.

Anyone else have experience with this?
 
Old 05-27-2005, 12:49 PM   #18
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
What would you say is the best live cd distro od linux for me to use? and where can I download and burn it from?
 
Old 05-27-2005, 01:21 PM   #19
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
I don't use live cds. I use slackware and it has a live cd distro
called slax. Never used it before.

We have LQ ISO here where you can download some cd images.
 
Old 05-31-2005, 07:03 AM   #20
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
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)


End Sub
 
Old 05-31-2005, 11:11 AM   #21
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
So you wanna do it in c(++) now? Just to let you know, youre
also going to have portability issues there if youre going
with both windows and linux.

vb is not my specialty (understatement of the year), but I'll look
at it if I get a chance.

Like I said, I love c and c++, but if portability is a must, then use java.

Here's a link where you can at least start trying to translate some
of those string functions:
java string class
 
Old 05-31-2005, 11:42 AM   #22
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
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.
 
Old 05-31-2005, 11:49 AM   #23
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
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.

Am I correct in saying that?
 
Old 05-31-2005, 11:54 AM   #24
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
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
 
Old 05-31-2005, 01:50 PM   #25
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
Quote:
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?
 
Old 06-01-2005, 07:10 AM   #26
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Ok,

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.
 
Old 06-01-2005, 08:39 AM   #27
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
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?
 
Old 06-01-2005, 08:59 AM   #28
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
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.
 
Old 06-01-2005, 09:47 AM   #29
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
Quote:
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.
What program are you passing those values to? Are you passing them
to the video recorder?


Quote:
I know nothing about php and have no idea what apache is either.
Apache is the mainstream *nix web server, and php is a programming
language that's a lot simpler than java.

If you used php, you would be sending the data to a particular url
where a php script would handle it, like this:
Code:
http://myserver.net/handleValues.php?val1=10&val2=20....
PHP Code:
<?php

$val1
$_GET['val1'];
$val2$_GET['val2'];
.......

// then here insert values to db or video recorder, or whatever
?>
That php code looks a lot easier than java huh?
 
Old 06-01-2005, 09:56 AM   #30
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting php5 socket functions to php3 socket functions mrobertson Programming 0 06-23-2005 09:11 AM
time functions in a c program mbacke Programming 3 04-18-2005 02:42 PM
Calling User-space program functions from Kernel modules shivanu Programming 1 03-05-2005 02:11 PM
The impact of rapidly advancing technology on society carrja99 General 4 03-31-2003 09:09 AM
pointers to functions/member functions champ Programming 2 03-28-2003 06:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration