�� HTTP���������߂̃��C�u���� BeOS�炵���R�[�h�̗��K���Ă����Ă݂܂����B ��͂�HTTP����y�Ɉ����Ȃ��ƂȂɂ��ƕs�ւł����B �����Ƃ��Ă�A�񓯊��ȓǂ���݂��T�|�[�g����񓯊����\�b�h��A Translator�Ȃǂɂ��̂܂܎g����BPositionIO���p�������������\�b�h�������Ă���_���������܂��B
�񓯊����\�b�h��AWinSock�̔񓯊����[�h�ɋ߂�������A������Ƀu���b�N�����ɕԂ�܂��B ���̌�R���X�g���N�^�Ŏw�肳�ꂽBLooper�I�u�W�F�N�g�ɑ΂��A�����󋵂����b�Z�[�W�Ƃ��� �ʒB���܂��B�ǂ����󋵂𒀎���ʂɔ��f������������A�p�t�H�[�}���X���ׂ����R���g���[�� ���������ɗL���ł��B
�������\�b�h��A���̃t�@�C���ǂ���݂Ɠ��l�ȋC�y���Ŏg����̂������ł��BSeek���g���܂��B �ǂ���݂��������Ă��Ȃ��f�[�^��ǂ����Ƃ������ɂ�A�ǂ���ݑ��̃X���b�h��A�K�v�ȕ����� �f�[�^���͂��܂ňꎞ�I�Ƀu���b�N���܂��BBPositionIO���p�����Ă���̂�ATranslator�� ���̂܂ܓn����̂�A�E�F�u��̉摜���Translator�œW�J����ȂǂƂ������g�������ł��܂��B
���񓯊����[�h�̃T���v���ׂ��������������̂�A���s����������I�Ȃ̂Ƃ�A�኱���G�Ɋ����邩������܂���B
[http_test1.cpp]
#include <Be.h> #include "TxBTcpHttp.h" // �ñ“¯Šï¿½ï¿½ï¿½ï¿½f�� class MyApp: public BApplication{ private: TxBTcpHttp *http; public: MyApp(void): BApplication("application/x-vnd.toyoshima-house.http_test1"), http(NULL) { }; ~MyApp(void) { if (NULL != http) delete http; } virtual void ReadyToRun(void) { http = new TxBTcpHttp(this); http->SetUserAgent("HTTP Test Client / BeOS"); http->SetServer("www.be.com", 80); http->Get("/"); }; virtual void DispatchMessage(BMessage *msg, BHandler *target) { switch (msg->what) { case TxB_HTTP_NOTIFY: int8 type; if (B_OK != msg->FindInt8(TxB_HTTP_NOTIFY_TYPE, &type)) break; switch (type) { case TxB_HTTP_ERROR:{ int32 code; const char *str; msg->FindInt32(TxB_HTTP_NOTIFY_ERRNO, &code); msg->FindString(TxB_HTTP_NOTIFY_MESSAGE, &str); printf("Error %d: %s\n", code, str); Quit();} case TxB_HTTP_HOST_RESOLVED:{ int32 addr; int16 port; msg->FindInt32(TxB_HTTP_NOTIFY_ADDRESS, &addr); msg->FindInt16(TxB_HTTP_NOTIFY_PORT, &port); printf("Connecting %d.%d.%d.%d:%d ... ", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff, port); fflush(stdout); break;} case TxB_HTTP_CONNECTED: puts("Connected"); break; case TxB_HTTP_STATUS:{ int16 status; const char *str; msg->FindInt16(TxB_HTTP_NOTIFY_STATUS, &status); msg->FindString(TxB_HTTP_NOTIFY_MESSAGE, &str); printf("Status: %d %s\n", status, str); break;} case TxB_HTTP_HEADER_COMPLETE: puts("Header Complete"); break; case TxB_HTTP_CONTENT_LENGTH:{ int32 length; msg->FindInt32(TxB_HTTP_NOTIFY_LENGTH, &length); printf("Content-Length: %d\n", length); break;} case TxB_HTTP_COMPLETE:{ int32 length; msg->FindInt32(TxB_HTTP_NOTIFY_LENGTH, &length); printf("Complete: %d\n", length); char *buffer = new char[length + 1]; size_t slen = length; if (NULL != buffer) { http->AsyncRead(buffer, slen); buffer[length] = 0; puts(buffer); } Quit();} case TxB_HTTP_BUFFER_CHANGED:{ int32 newby; int32 current; int32 length = -1; msg->FindInt32(TxB_HTTP_NOTIFY_NEWBY, &newby); msg->FindInt32(TxB_HTTP_NOTIFY_CURRENT, ¤t); msg->FindInt32(TxB_HTTP_NOTIFY_LENGTH, &length); printf("Read %d bytes: %d/%d\n", newby, current, length); break;} } break; default: BApplication::DispatchMessage(msg, target); break; } }; }; int main(int argc, char **argv) { MyApp app; return app.Run(); }
���������[�h�̃T���v��������͔��ɊȒP�ł��B���������ꂾ���̃R�[�h�ŃE�F�u��̉摜�t�@�C����\�����邱�Ƃ��ł��܂��B Java�ł������܂ŊȒP�ɂ�����Ȃ��ł���i��j�B
[http_test2.cpp]
#include <Be.h> #include "TxBTcpHttp.h" // �������f�� class MyApp2: public BApplication{ public: MyApp2(void): BApplication("application/x-vnd.toyoshima-house.http_test2") { }; virtual void ReadyToRun(void) { // �܂��ǂ���݂��J�n�����Ă����ƌ����I TxBTcpHttp *http = new TxBTcpHttp(); http->SetServer("www.tk.xaxon.ne.jp", 80); http->Get("/~toyoshim/cg/title_mai.jpg"); // �\���p�̑������� BWindow *win = new BWindow(BRect(100, 100, 100 + 320, 100 + 240), "HTTP TEST 2", B_TITLED_WINDOW, B_NOT_RESIZABLE); BView *view = new BView(win->Bounds(), "graphic", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); win->AddChild(view); // BPositionIO�Ƃ���Translator�ɂԂ����� BBitmap *bmp = BTranslationUtils::GetBitmap(http); delete http; // ���Ƀy�^�I view->SetViewBitmap(bmp); win->Show(); }; }; int main(int argc, char **argv) { MyApp2 app; return app.Run(); }
���_�E�����[�hï¿½Æ‚è‚ ï¿½ï¿½ï¿½ï¿½ï¿½A���J���Ƃ��܂��B�����Ȃ�C�����邩������܂��ñ‚ª�A �d�l��ς��邱�Ƃ͂Ȃ��Ǝv���܂��B�������g�g���ñ‚·‚�Å�i�Î�j�B ���C�Z���X��Artistic������ɂ��Ă����܂��B����E�v�]�͊��}�B ���P�����R�[�h�͂����Ɗ��}�B