sending a file across sockets.

This is a discussion on sending a file across sockets. within the C Programming forums, part of the General Programming Boards category; An extra $50/month. You should have thought of this earlier, you could have got LV* in on the action: Google ...

  1. #16
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    An extra $50/month.

    You should have thought of this earlier, you could have got LV* in on the action:
    Google Fiber for Communities: Project Overview
    Apparently Topeka, Kansas went so far as to officially rename itself "Google" with high hopes.

    * sadly, my fav Vegas song ("UNLV Oedipus" by the Thundacats) is not on youtube...miss out
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #17
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Well you could do worse thannnYouTube - Viva Las Vegas
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #18
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Dude -- UNLV Oepidus starts with EXACTLY the same sequence of sounds (a ball in a roulette wheel then the one armed bandit).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #19
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,058
    Quote Originally Posted by MK27 View Post
    Servers bind and listen.

    Clients connect. So it is either one or the other, not both -- bind, listen, then connect would be silly.
    Yep! my fault, guess I was thinking of server-side socket calls and accept().

    Quote Originally Posted by MK27 View Post
    However, the way mushy is doing it is wrong, since it looks like an attempt to connect to one's self.
    Nope! that's fine if the server-side socket binds to INADDR_ANY and looks like it is.

  5. #20
    Registered User
    Join Date
    Jan 2008
    Posts
    79
    I found this thread, i had forgot about it. I started two similar theads the other day on this same topic as i was off holidaying for a couple of months and am trying to get my head round it again.

    Needless to say i still can't work out how to send a file across a socket. I was wondering if anyone knows a basic working example of how to do it, or even has one.

    I think the time passed since i first started this thread shows that its not for any kind of project or assignment or anything. Its just something personal. I know people think working it out for myself would help me learn better.

    But im genuinely the opposite, if i can get it working, then its like getting a new toy and i can think of more programs i want to build using the concepts and will learn more from that.

    So if anyone has it it would be great

  6. #21
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657
    How about you stop posting multiple topics, eh? Why resurrect an old topic with "I still have this problem from six months ago and I have multiple other threads on it so please help me"??? Inconsiderate and pointless. If someone wants to help you with your other topics, they will.

  7. #22
    Registered User
    Join Date
    Jan 2008
    Posts
    79
    lol. You need to get out more if that has annoyed you.

  8. #23
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    265
    You should have made another topic.

    Anyway, it seems that previous posters have given you enough information to complete this. wrap your servers code in a loop that writes while there are more bytes to send. I would use a SOCK_STREAM for this. You'll probably want to open the file in binary mode. and write() to the socket. Your client will read() from the socket() while read() > 0.

    Clients typically: socket() connect();

    servers: socket() bind() listen() accept(); then some loop.

  9. #24
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657
    No, he doesn't need yet another topic. He needs to not bump 6-month-old topics and go read Beej's Guide and understand it.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 02:04 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21