Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

WebsiteWill

Help Please

This topic is 5483 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I hate to keep asking these questions here but I get no responses from anyone else regarding this. I''m trying to compile the source code fromt he book Unix Network Programming and am having problems finding some of the code. The code by itself will not compile on my system so I am having to copy/paste and write code that i cannot find. This is the very first example in the book, the daytimeserver listed on page 13 for anyone who has it. The compiler is telling me that the wrapper functions Write and Close are not defined. I''ve looked in the file wrapsock.c and can confirm that they are not there. I have no idea where else they would be. I''m having to edit the unp.h to suit my system for compiles as it keeps saying something in there is redefined. I''m hoping that as I work through the book sorting out these issues that it will help me learn so I''m kinda greatful for the mistakes I am finding but it''s beginning to be more hindersome than helpful. If anyone out there is familiar with this book and has had similar issues please let me know. Help greatly appreciated, Webby

Share this post


Link to post
Share on other sites
Advertisement
My first question is what system are you trying to compile on? And the code that you are adding, is it copied verbatim from the book? I believe there''s some errata on his site about code that doesn''t work/compile. I''ll take a look and try to help you out, but please let me know what OS/version you are using.

Share this post


Link to post
Share on other sites
In the version of the code that I downloaded tonight, there was a file pathed:
unpv12e/lib/wrapunix.c

This file contains the functions you will want... make sure you follow the directions and run configure etc... it might take some work getting this stuff to work correctly if you are on a windows system.

here for your reference:


void
Write(int fd, void *ptr, size_t nbytes)
{
if (write(fd, ptr, nbytes) != nbytes)
err_sys("write error");
}

void
Close(int fd)
{
if (close(fd) == -1)
err_sys("close error");
}



For future reference, depending on platform there are some handy tricks for searching a large codebase:
-In MS DevStudio you can use "edit->Find in files"
-In most *nix you can do:
find . -name "name" -exec grep -H "Write" {} ;\
where "name" is a regular expression for the filename (e.g. "*.c"), and "Write" is the case-sensitive string you are searching for.

Most likely you have not correctly run the included configure/autoconf scripts for the UNP code.

I wish you luck, email me if you need more help. Just as a note, I hate Stevens'' code samples and have another desk reference for checking my BSD code/syntax when needed. Otherwise, his books are A+ de-facto standard reference for people who write serious TCP applications/protocols.

Share this post


Link to post
Share on other sites
Thanks fingh.

I''m running Red Hat Linux for this. I''ve tried running the config scripts but have gotten some strange errors. There is another post just down the list from here with a question about that that noone answered yet. That''s when I decided to start reading the book and trying to piece the code examples together from scratch. Since his unp.h doesn''t like my system I go through it and deleted everything I didn''t immediately need for the current example. That''s when I found that I couldn''t locate Write and Close.

I think that using your find command above I should be OK for now. I have tried it out yet but I''m hoping I can use it to search an entire directory for specific words? That way I won''t have to type in the command to work on every single file until I find it.

Please take look at my earlier post as getting the configure script and make files to work correctly would be a great help though I think I will learn a lot more if I piece things together all the way like I am currently trying to do.

Thanks again,
Webby

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!