How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

I need to help writing a VERY basic C program that will open

Customer Question

I need to help writing a VERY basic C program that will open a socket and send a message from one socket to a different socket. It doesn't need to be complex it just needs to work in windows and be very basic. I have no idea where to start as i have never programmed in C or with sockets before.


 


Also the Assignment is Due Tuesday

Submitted: 9 months ago.
Category: Homework
Expert:  Josie-Mod replied 9 months ago.

Hello,

I'm Josie and I'm a moderator for this topic.

We have been working with our professionals to try to help you with your question. Sometimes it may take a bit of time to find the right fit.

I was checking to see if you had already found your answer or if you still need assistance from one of our professionals.

Please let me know if you wish to continue waiting or if you would like for us to close your question?

Also remember that JustAnswer has a multitude of categories to help you with all your needs from Pet to Legal.

Thank you,

Josie~Moderator

Customer: replied 9 months ago.

Continue

Expert:  Josie-Mod replied 9 months ago.
Hello

Thank you, XXXXX XXXXX continue to look for a professional to assist you. Please let me know if I can be of any further assistance while you wait.

Best,
Josie~Moderator
Expert:  Ingo U replied 9 months ago.
Hi,
What development tools are you using under windows?
Customer: replied 9 months ago.

I don't know what you mean?

Expert:  Ingo U replied 9 months ago.
I mean what compiler for example? Do you have Visual Studio perhaps?
Can you give some info about the class you are taking? It's a bit unusual to have an into C course start out with socket programming.
Customer: replied 9 months ago.

It is an internet networking course and i am using an online compiler. it is compilr.com. If i need to i can download visual studio. The class is an introduction course to the networking infrastructure.

Expert:  Ingo U replied 9 months ago.
OK, got it. I checked out compilr.com and think i'll be able to use it.
But are you sure about having to run under windows?
I uploaded my code I wrote for you in Visual Studio, assuming a windows environment, and the compilr told me I have to write for a linux environment.
I can certainly go down that route, but maybe you can provide some guidance before I proceed.
Thanks,
Ingo
Customer: replied 9 months ago.

My instructor gave me very little direction so let me email him and see what I can get. I just know that I use a windows machine so... yea

Customer: replied 9 months ago.

Instructor: Write a TCP Socket app that has a client talking to a server and do the same thing for UDP. For both cases you should have two processes/programs on one computer talking to each other via the socket protocol.

Expert:  Ingo U replied 9 months ago.
Hmm. Not very helpful...I don't quite see how we can do that on compilr.com - it only lets me create one project, and we need 4 (unless I pay money I suppose).
How about you install Visual Studio 2010 Express and we'll do it on the windows machine (I already have a TCP sample ready to go under VS2010)
Customer: replied 9 months ago.

Ok Ill definitely do that then.

Expert:  Ingo U replied 9 months ago.
Here is a VS2010 solution with the 4 programs:

http://wikisend.com/download/460038/BasicSocket.zip

It is currently configured to run the UDP pair when you run it (to run, go to Debug menu and select "Start Debugging")

To run the TCP versions you would go the Project menu, select "Set Startup Projects" , check the TCP projects and uncheck the UDP projects.

It's the most basic code I could come up with, it does absolutely no error checking or cleanup before exiting. I figured that's what you meant by basic. Let me know if you need anything else...
Regards,
Ingo U
Customer: replied 9 months ago.

my school gave out Visual studio 2012 how do i get this to run in 2012

Expert:  Ingo U replied 9 months ago.
I converted the solution to VS2012 for you, here it is:

http://wikisend.com/download/643498/BasicSocket_VS2012.zip

Let me know if you have any problems or questions!

Ingo
Customer: replied 9 months ago.

i cant figure out how to change the start up files

Expert:  Ingo U replied 9 months ago.
Does that imply you are at least able to run the UDP sender/receiver pair the way I sent it?
Customer: replied 9 months ago.

Yes I was able to run the file the way you have sent it. I just need to figure out how to run the tcp. Also how easy is it to split the program into 2 so I dont have to do this?

Customer: replied 9 months ago.

Yes I was able to run the file the way you have sent it. I just need to figure out how to run the tcp. Also how easy is it to split the program into 2 so I dont have to do this?

Expert:  Ingo U replied 9 months ago.
No problem, I'll make 2 individual solutions for you. Won't take long.
Customer: replied 9 months ago.

Awesome thank you my class is at 3pm so before tjen would be great

Expert:  Ingo U replied 9 months ago.
Here you go:

http://wikisend.com/download/889132/BasicSocket_VS2012.zip
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Ingo U and 6 other Homework Specialists are ready to help you
Customer: replied 8 months ago.

Alright so part 2 is that i need to create A socket server that can do this list.


While running on my computer the socket server needs to:



  • Open a Port with a designated address so that people can connect to it.

  • Allow people to connect to the server

  • Append a .txt file so that it keeps a running record of the people that ping the server (there IP address)

  • Allow people to pull the address book to see who has connected to the address



Create a client that connects to other peoples servers with an address. So when i run the Client i need to be able to connect to there server by typing in an address and then connecting to it.

Customer: replied 8 months ago.

willing to pay 80$ for it to be finished by tomorrow night but if need be i would like to have it no later than Tuesday night for 60$

Expert:  Ingo U replied 8 months ago.
Hi,
I think I can do this for you. You mean a TCP server, right? And should the server automatically send the contents of the address book as soon as a client connects?
Customer: replied 8 months ago.

Yes a TCP Socket Server and no have them connect say welcome to jordans server and then ask them if they would like to download the .txt file with all of the peoples addresses that have connected to me. They need the .txt file to be able to connect to more people. is there any chance you could do this in C++ or is it easier in C. i know it would be easier for me to understand if it was in C++. Again it can be very basic. No need for any Extra's

Expert:  Ingo U replied 8 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.

Customer: replied 8 months ago.

So how does the client work there are sections of code i dont understand?

Expert:  Ingo U replied 8 months ago.
I'll try to add some comments.
Customer: replied 8 months ago.

oh awesome thank you!

Expert:  Ingo U replied 8 months ago.

Here's an updated client cpp file.

 

http://www.mediafire.com/?atkysvo935f78u8

 

If there are specific sections you don't understand, maybe write your questions directly in the file as comments and upload the file again.

Customer: replied 8 months ago.

After a long discussion with my instructor i have finally figured out what he is asking for. He wants me to create a server client program like you did, but instead of using an IP address he wants us to use host names. He said that i needed to look into get host name and set host name in the winsock library. He also said that when people connect to my server. I need to give them a Number so for example 8829421 then they need to be able to download my .txt file like we did that contains the host name of each person that connects to me. the other thing is that i need my client to be able to show my host name for which i am connecting from.

Customer: replied 8 months ago.

also i just tried to send you 40$ for the first portion of the program i was going to send you the rest when we finished please let me know if you have gotten it or not. it errored when i tried to submit it

Expert:  Ingo U replied 8 months ago.
OK, I'll look into it. Thanks for the attempt to partial pay, but it didn't show up. You could try it as a bonus, that usually works.
Customer: replied 8 months ago.

i just got it to go through as a bonus so you should receive it soon. ill pay the other 40 when we finish. thanks for being patient and helping me out!

Expert:  Ingo U replied 8 months ago.
It may take a while to go through, but I'll keep working. I'll keep checking and get back to you with any news or questions.
Customer: replied 8 months ago.

definitely take the rest of the week if you need to. he isnt strict on due date as long as i can show him im working on it.

Expert:  Ingo U replied 8 months ago.
OK, help me clear some things up:
- You don't want IP addresses to be used directly - client connects to the server by specifying a host name, and server maintains the address book using the host names of the clients that have connected. Correct? No problem.
- I don't see where one would use sethostname() in this. Why would either client or server try to change their own name? Windows probably won't even let you.
- What's the purpose/meaning and usage of the "Number" given to a client that connects? How is it generated? Is it a user ID? Does it need to be stored anywhere? I need more specs on this.
Thanks,
Ingo
Customer: replied 8 months ago.

On so the number is just a string it can be in the Welcome to my server your number is this. He did say it needed to be a 64 bit number not sure what that is but yea. Its mainly so that when i turn in the txt file he can reconcile with other students to make sure they actually connected to my server.


 


As for set host name im not sure if it something i need to use or if he was trying to give me an idea on where to look for information.


 


I do know however is that people need to connect to my machines host name which in sense will have my server running. Now im not sure how to find my exact host name(DNS i believe) i do know that when i was doing an ip config in CMD prompt it said something like mobile.asu.edu

Expert:  Ingo U replied 8 months ago.
I see, so in this class the students' clients will connect to other students' servers? If so, I should also make the port # something the client is prompted for, because right now it's hard-coded to 50000. If other people's servers use a different port, you'll need to be able to enter it at run time.
Customer: replied 8 months ago.

one of my class mates sent an email out with this address.

I am expecting TCP connections at adelorme.no-ip.biz port 5003


 


Hope that helps

Expert:  Ingo U replied 8 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.

Customer: replied 8 months ago.

The number is just a number that the client logging into my server is given so when my professor grades the lab, i say here is the number that they should have if they don't have this number they never connected to my server. And yea i guess the its more of a log book than an address book. but i like the way that you have it. and is the 64bit number a random number or a static?


 

Expert:  Ingo U replied 8 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.

Customer: replied 8 months ago.

does it pair the number with the address they connect with? or how will i give that info to my instructor?

Expert:  Ingo U replied 8 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 8 months ago.

how do i know my server hostname?

Expert:  Ingo U replied 8 months ago.
You mean the machine running the server?
Customer: replied 8 months ago.

yes. i did a google search for my host name and tried to connect the client from the machine that i was running the server on to try and test it but i think i broke it lol. The client went haywire.

Expert:  Ingo U replied 8 months ago.
Download this:
http://www.mediafire.com/?115ty0d8dir687b

Replace the JordansServer.cpp file; this one displays you a startup message with the host name you're running on.
Keep in mind that this is where it can get tricky. Depending on your network setup, machines may be configured to prevent connecting to each other like this (firewall).
Are you at a school campus of some kind? Even within the campus network, there may be protections in place to prevent viruses etc. I'd hope you have some kind of isolated lab where you can play around to your hearts content.
Customer: replied 8 months ago.

ok so this is were i get confused it says my hostname is JordanSmith-PC. Now how would someone use that address to connect to me. There could be a ton of people with JordanSmith-PC. How do people know that it is my computer? And yes i am on a college campus. I need to be able to connect to peoples clients through the internet.

Expert:  Ingo U replied 8 months ago.

Like I said this is where it gets tricky. Are all the other people on campus too?

Open a cmd prompt and type 'nslookup JordanSmith-PC'. What do you get?

You may need to get your instructor or campus IT guy involved because it depends entirely on how your network is configured, and there are a gazillion ways people do it.

Customer: replied 8 months ago.

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Jordan Smith>nslookup JordanSmith-PC



Server: asudns3.asu.edu
Address: 129.219.17.200
Aliases: 200.17.219.129.in-addr.arpa

Non-authoritative answer:
Name: JordanSmith-PC.mobile.asu.edu
Address: 10.140.112.248

Expert:  Ingo U replied 8 months ago.

Aha. So try and see if your client (or one of your friends', even better) can connect (from another computer) to the fully qualified name JordanSmith-PC.mobile.asu.edu at port 50000

 

 

Customer: replied 8 months ago.

My buddy was able to connect with just JordanSmith-PC on the same wifi when he gets home he is going to try and connect from his network. i gave him the client.exe so we will see....

Expert:  Ingo U replied 8 months ago.
Any luck?

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience