정리

printf Type Field Characters & Size Specification

저장소/VC++

나는 멍청해서 맨날 잊어버리니까...ㅜㅜ

아.. 내용 짤리는데 스크롤도 안 되고... ㅜㅜ


출처

MSDN : printf Type Field Characters

MSDN : Size Specification



printf Type Field Characters

Character

Type

Output format

c

int orwint_t

When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character.

C

int orwint_t

When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character.

d

int

Signed decimal integer.

i

int

Signed decimal integer.

o

int

Unsigned octal integer.

u

int

Unsigned decimal integer.

x

int

Unsigned hexadecimal integer, using "abcdef."

X

int

Unsigned hexadecimal integer, using "ABCDEF."

e

double

Signed value having the form [ – ]d.dddd e [sign]dd[d] where d is a single decimal digit, dddd is one or more decimal digits, dd[d] is two or three decimal digits depending on the output format and size of the exponent, and sign is + or –.

E

double

Identical to the e format except that E rather than e introduces the exponent.

f

double

Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.

g

double

Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.

G

double

Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).

a

double

Signed hexadecimal double precision floating point value having the form [−]0xh.hhhh dd, where h.hhhh are the hex digits (using lower case letters) of the mantissa, and dd are one or more digits for the exponent. The precision specifies the number of digits after the point.

A

double

Signed hexadecimal double precision floating point value having the form [−]0Xh.hhhh dd, where h.hhhh are the hex digits (using capital letters) of the mantissa, and dd are one or more digits for the exponent. The precision specifies the number of digits after the point.

n

Pointer to integer

Number of characters successfully written so far to the stream or buffer; this value is stored in the integer whose address is given as the argument. See Security Note below.

p

Pointer to void

Prints the argument as an address in hexadecimal digits.

s

String

When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached.

S

String

When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached.


Size Specification

To specify

Use prefix

With type specifier

long int

l (lowercase L)

diox, or X

long unsigned int

l

oux, or X

long long

ll

diox, or X

short int

h

diox, or X

short unsigned int

h

oux, or X

__int32

I32

diox, or X

unsigned __int32

I32

oux, or X

__int64

I64

diox, or X

unsigned __int64

I64

oux, or X

ptrdiff_t (that is, __int32 on 32-bit platforms, __int64 on 64-bit platforms)

I

diox, or X

size_t (that is, unsigned __int32 on 32-bit platforms, unsigned __int64 on 64-bit platforms)

I

oux, or X

long double

l or L

f

Single-byte character with printf functions

h

c or C

Single-byte character with wprintf functions

h

c or C

Wide character with printf functions

l

c or C

Wide character with wprintf functions

l

c or C

Single-byte – character string with printf functions

h

s or S

Single-byte – character string with wprintf functions

h

s or S

Wide-character string with printf functions

l

s or S

Wide-character string with wprintf functions

l

s or S

Wide character

w

c

Wide-character string

w

s

Thus to print single-byte or wide-characters with printf functions and wprintf functions, use format specifiers as follows.

To print character as

Use function

With format specifier

single byte

printf

chc, or hC

single byte

wprintf

Chc, or hC

wide

wprintf

clclC, or wc

wide

printf

ClclC, or wc




'저장소 > VC++' 카테고리의 다른 글

Stream Manipulators  (0) 2013.08.16
System Performance Monitoring  (0) 2013.08.06
SQLite - Transaction과 Database Lock  (0) 2013.07.25
MIDL Language Reference  (0) 2013.07.12
P2P  (0) 2013.06.12

SQLite - Transaction과 Database Lock

저장소/VC++

Transaction과 Lock 상태의 이해가 반드시 필요하다.


(보기 불편해서 쬐끔 수정...)



Lock type

unlocked, shared, reserved, pending, exclusive (unlocked 를 제외하고 모두 제각각 Lock 있음)


unlocked : database에 연결, begin transaction으로 Tr 시작 상태

shared : DB에서 read 하려고 하는 모든 세션이 획득해야 함 - 다중 세션에서 read 가능하고, shared 락은 활성화 되어 있지만 어떤 세션도 wrtie는 안됨

reserved : wrtie 하고자 하는 세션은 reserved 획득해야 함. 다른 read 세션은 방해하지 않으며, 새로 접근 하는 read 세션도 허용한다. 적용하는 변경 내역은 메모리에 캐시 된다.

exclusive : reserved 락을 획득한 세션에서 변경 내역(or Tr)을 commit 하려면 획득해야 함

pending : reserved 가 exclusive 를 획득하기 위해서는 pending 을 먼저 획득해야 함 - pending lock을 획득하면 새로운 shared lock 제한하고, shard lock들이 모두 끝나길 기다린다. 기다림이 끝나면 pending -> exclusive로 전환되면서 모든 사항 반영한다.


요약 : READ : unlocked -> shared

         WRITE : unlocked -> shared -> reserved -> pending -> exclusive

 


Transaction Type (deferred, immediate, exclusive)

begin [ deferred | immediate | exclusive ] transaction;


deferred : Tr type을 명시하지 않았을 경우 default 값이며, 어떤 락도 생성하지 않고, unlocked로 시작함.

DB의 첫번째 읽기 연산에서 shared lock 획득 시도.

DB의 첫번째 쓰기 연산에서 reserved lock 획득 시도.

immediate : begin 명령이 실행 되자마자 reserved 락 획득 시도.

성공 시, 어떤 다른 세션도 DB에 쓸 수 없게 begin immediate 명령이 보장함.

기존에 shared lock 획득 세션은 읽기 계속 할 수 있으나, 새로운 세션에서는 읽지 못하게 reserved lock이 막음.

다른 어떠한 세션도 begin immediate 나 begin exclusive 명령을 성공적으로 실행할 수 없음.

      ERROR CODE : SQLITE_BUSY

이렇게 시작된 Tr은 데이터 변경은 가능하나 commit은 불가. commit 수행 시

      ERROR CODE : SQLITE_BUSY

shared lock을 획득한 다른 세션에서 DB 읽고 있기 때문. 해당 세션들 shared lock 모두 해제 후 Tr commit 가능하다.

exclusive : Tr은 해당 DB의 exclusive lock 획득.

immediate 와 유사하나, 이 lock을 획득하면 어떤 다른 세션도 그 DB를 사용할 수 없어서 읽기/쓰기를 마음대로 할 수 있다.

 

DB에 쓰기에 있어서 concurrent 를 고려해야 하는 상황 이라면 일단은 transaction type을 deferred 가 아닌 것으로 주어 동기화 이슈를 회피 가능하다.




추가 참고 :



'저장소 > VC++' 카테고리의 다른 글

System Performance Monitoring  (0) 2013.08.06
printf Type Field Characters & Size Specification  (0) 2013.07.29
MIDL Language Reference  (0) 2013.07.12
P2P  (0) 2013.06.12
Visual Studio 2012 Debugging - Parallel Stack  (0) 2013.05.21

MIDL Language Reference

저장소/VC++

MIDL Language Reference


MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/aa367088(v=vs.85).aspx



참고:

http://www.codeproject.com/Articles/38254/A-Beginner-Tutorial-for-Writing-Simple-COM-ATL-DLL

http://www.sysnet.pe.kr/Default.aspx?mode=3&sub=0&detail=1&pageno=0&wid=791&rssMode=1&wtype=0

http://www.asmcommunity.net/forums/topic/how-many-parameters-does-idispatchinvoke-have/

'저장소 > VC++' 카테고리의 다른 글

printf Type Field Characters & Size Specification  (0) 2013.07.29
SQLite - Transaction과 Database Lock  (0) 2013.07.25
P2P  (0) 2013.06.12
Visual Studio 2012 Debugging - Parallel Stack  (0) 2013.05.21
boost library build for windows  (0) 2013.05.20

TCP flag(URG, ACK, PSH, RST, SYN, FIN)

저장소/잡다한거

출처 : http://pmj0403.tistory.com/entry/TCP-flagURG-ACK-PSH-RST-SYN-FIN



TCP flag(URG, ACK, PSH, RST, SYN, FIN)

TCP(Transmission Control Protocol)는 3-WAY Handshake 방식을 통해 두 지점 간에 세션을 연결하여 통신을 시작 하고 4-WAY Handshake를 통해 세션을 종료하여 통신을 종료 합니다.

이러한 세션연결과 해제 이외에도 데이터를 전송하거나 거부, 세션 종료 같은 기능이 패킷의 FLAG 값에 따라 달라지게 되는데, TCP FLAG는 기본적으로 6 가지로 구성됩니다.

 

FLAG 순서

+-----+-----+-----+----+-----+----+

| URG  | ACK | PSH | RST | SYN | FIN |

+-----+-----+-----+----+-----+----+

각각 1비트로 TCP 세그먼트 필드 안에 cONTROL BIT 또는 FLAG BIT 로 정의 되어 있다.

 

 

SYN(Synchronization:동기화) - S : 연결 요청 플래그

TCP 에서 세션을 성립할 때  가장먼저 보내는 패킷, 시퀀스 번호를 임의적으로 설정하여 세션을 연결하는 데에 사용되며 초기에 시퀀스 번호를 보내게 된다.

 

ACK(Acknowledgement) - Ack : 응답

상대방으로부터 패킷을 받았다는 걸 알려주는 패킷, 다른 플래그와 같이 출력되는 경우도 있습니다.
받는 사람이 보낸 사람 시퀀스 번호에 TCP 계층에서 길이 또는 데이터 양을 더한 것과 같은 ACK를 보냅니다.(일반적으로 +1 하여 보냄) ACK 응답을 통해 보낸 패킷에 대한 성공, 실패를 판단하여 재전송 하거나 다음 패킷을 전송한다.

 

RST(Reset) - R : 제 연결 종료
재설정(Reset)을 하는 과정이며 양방향에서 동시에 일어나는 중단 작업이다. 비 정상적인 세션 연결 끊기에 해당한다. 이 패킷을 보내는 곳이 현재 접속하고 있는 곳과 즉시 연결을 끊고자 할 때 사용한다.

 

PSH(Push) - P : 밀어넣기

TELNET 과 같은 상호작용이 중요한 프로토콜의 경우 빠른 응답이 중요한데, 이 때 받은 데이터를 즉시 목적지인 OSI 7 Layer 의 Application 계층으로 전송하도록 하는 FLAG. 대화형 트랙픽에 사용되는 것으로 버퍼가 채워지기를 기다리지 않고 데이터를 전달한다. 데이터는 버퍼링 없이 바로 위 계층이 아닌 7 계층의 응용프로그램으로 바로 전달한다.

 

URG(Urgent) - U : 긴급 데이터
Urgent pointer 유효한 것인지를 나타낸다. Urgent pointer란 전송하는 데이터 중에서 긴급히 전당해야 할 내용이 있을 경우에 사용한다. 긴급한 데이터는 다른 데이터에 비해 우선순위가 높아야 한다. 
 EX) ping 명령어 실행 도중 Ctrl+c 입력

 

FIN(Finish) - F : 연결 종료 요청
세션 연결을 종료시킬 때 사용되며 더이상 전송할 데이터가 없음을 나타낸다.

 

그 외

 

Placeholder             
패킷의 플래그에 SYN, FINISH, RESET, PUSH등의 플래그가 설정 되어 있지 않은 경우 이 플래그가 세팅된다. 이 플래그는 ACK플래그와 함께 사용되는 경우도 있다.


P2P

저장소/VC++

잡다하게 기초 자료 수집



파일 전송 시간 계산

전체 크기 : 받은 크기 = 전체 전송 시간 : 현재까지 걸린 시간

전체 전송 시간 = 현재까지 걸린 시간 * 전체 크기 / 받은 크기

남은 시간 = 전체 전송 시간 - 현재까지 걸린 시간


네트워크 전송 속도

http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=50&MAEULNo=20&no=660517&ref=660517



IOCP 파일 쓰기

http://greenfishblog.tistory.com/153



TCP 패킷 스택의 이해

http://helloworld.naver.com/helloworld/47667


P2P

http://ko.wikipedia.org/wiki/P2P

http://www.brynosaurus.com/pub/net/p2pnat/#rfc2460#rfc2460


tracker

http://gsroom.tistory.com/101 (tracker server PHP sample)

http://gsroom.tistory.com/104 (tracker server PHP sample - not  using db)

http://en.wikipedia.org/wiki/BitTorrent_tracker

http://trxy2.tistory.com/5 (private tracker)


bittorrent

http://ko.wikipedia.org/wiki/%EB%B9%84%ED%8A%B8%ED%86%A0%EB%A0%8C%ED%8A%B8

http://blog.naver.com/samsjang/40041869821

http://blog.naver.com/samsjang/40041874214

http://blog.naver.com/samsjang/40041904452


libtorrent

http://www.rasterbar.com/products/libtorrent/manual.html

https://code.google.com/p/libtorrent/

http://sykimeo.blog.me/140187591782

http://softwerkz.net/2009/09/libtorrent/

http://blog.naver.com/kdi0909/40167148400


WIN32_LEAN_AND_MEAN

_WIN32_WINNT=0x0600

_CRT_SECURE_NO_DEPRECATE

BOOST_ASIO_HASH_MAP_BUCKETS=1021

BOOST_FILESYSTEM_VERSION=2

WITH_SHIPPED_GEOIP_H

BOOST_ASIO_SEPARATE_COMPILATION

BOOST_ASIO_ENABLE_CANCELIO

TORRENT_USE_TOMMATH

..\include;..\..\..\boost\boost_1_53_0;"..\..\..\openssl\openssl-1.0.1c\inc32"

libeay32.lib ssleay32.lib

"..\..\..\openssl\openssl-1.0.1c\out32\VC9_x86";..\..\..\\boost\boost_1_53_0\stage\lib


P4P

http://trendofit.tistory.com/223

http://www.zdnet.com/blog/storage/p4p-faster-smarter-p2p/303


홀펀칭

http://www.gpgstudy.com/forum/viewtopic.php?t=7421&highlight=tcp+hole+punching

http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=50&MAEULNo=20&no=719686&ref=719686

http://blog.bagesoft.com/607

http://coderoid.tistory.com/50

http://ncanis.tistory.com/11

http://devdbref.tistory.com/14

http://blog.naver.com/pointedsword/20046099017

http://blog.naver.com/khs01016/48881138

http://blog.naver.com/chikicon/60036633811









'저장소 > VC++' 카테고리의 다른 글

SQLite - Transaction과 Database Lock  (0) 2013.07.25
MIDL Language Reference  (0) 2013.07.12
Visual Studio 2012 Debugging - Parallel Stack  (0) 2013.05.21
boost library build for windows  (0) 2013.05.20
WinHTTP Equivalents to WinINet Functions  (0) 2013.04.17

Virtual CloneDrive - freeware

도구

가상 이미지 드라이브로 무려 무료!

사용하기도 편하고 무엇보다 무료라서 더 좋다!


http://www.slysoft.com

http://www.slysoft.com/en/download.html


적어둬야 기억을 하지.

'도구' 카테고리의 다른 글

freeCommander - freeware  (0) 2013.08.28

Visual Studio 2012 Debugging - Parallel Stack

저장소/VC++

Visual Studio 2012 의 디버그 도구 중 병렬 스택에 관한 간략한 내용.


디버깅 중 설정한 중단점에 잡혔을 때 병렬 스택 기능을 통해 각 스레드 별 호출 스택을 확인할 수 있다.

상태 파악하기 상당히 좋다. 쬐금 감동받아버렸네.. 휴우..



메뉴 -> 디버그 -> 창 -> 병렬 스택


병렬 스택


우왕 굳

'저장소 > VC++' 카테고리의 다른 글

MIDL Language Reference  (0) 2013.07.12
P2P  (0) 2013.06.12
boost library build for windows  (0) 2013.05.20
WinHTTP Equivalents to WinINet Functions  (0) 2013.04.17
Command Line Build : VCBuild와 MSBuild 그리고 devenv  (0) 2013.04.16

boost library build for windows

저장소/VC++

boost, 저도 참 좋아하는데요...

제가 한 번 먹.. 써보도록 하겠습니다.


일단 링크를...

boost : http://www.boost.org/


 windows installer 버전도 있다는 사실!

boostpro.com이 문을 닫아버려 1.51.0 버전까지만 installer가 제공된다.

이전 버전의 다운로드는 요기로~


친절하게 설명된 내용이 있어 알았음.

http://jeffreygoines.tistory.com/14


다음은 windows 환경에서 boost library를 빌드 하는 방법이 설명된 곳

http://anster.egloos.com/2157882




간략히 순서를 정리하자면 다음과 같다.

앵간한거는 걍 include해서 써도 되지만 일부 library는 빌드가 반드시 필요하다고 한다.

어디선가 봤는데 어딘지는 모르겠고.. 영어 해석은 잘 안 되고.. 후..

걍 줴다 만들자.

요 옵션으로 확인 가능하다고 한다.

bjam --show-libraries


1. boost library를 받는다.

windows용은 확장자가 zip인 것을 받아야 한다. zip이 windows용이다. 이 내용 어디서 봤는데.. 어디서 봤더라?

받았으면 압축을 풀고 준비.


2. bjam.exe와 b2.exe를 만들어야 하니까 bootstrap.bat을 실행한다.

bjam은 로 부스트 컴파일을 위한 jamfile parser로 뭐라뭐라 했는데.. 까묵 ㅠㅠ

bjam.exe --help를 치면 도움말 나온다.

b2.exe도 동일하게 나온다. 내부적으로 bjam을 사용하나보다.

웹 문서는 요기

http://www.boost.org/boost-build2/doc/html/index.html

http://www.boost.org/boost-build2/doc/html/bbv2/overview/invocation.html


영어만 보면 어지러워 @_@

복군님 블로그에서 발췌

http://anster.egloos.com/2157882


옵션에 대해 잘 정리된 곳 -> Viper Wiki


bjam 사용법 중 다음이 중요하다.

bjam [options] [properties] [install|stage]


install은 헤더 파일과 빌드된 라이브러리 파일을 설치하고

stage는 빌드된 라이브러리 파일만 설치한다.


install 옵션은 시간도 오래 걸리고 용량도 냠냠 하니까 stage를 권장.

내 스스드는 언제나 용량 부족 ㅠㅠ


3. 급하다! 결론만 간단히!

Visual Studio 컴파일러를 이용해 빌드해야 하니까 원하는 버전의 command prompt를 실행한다.

platform 버전에 맞게~

그담은 boost root 경로로 이동해서 아래와 같이 실행하면 된다.


4. 빌드된 boost library를 보면 이름이 뭐 이따위야 싶은데 네이밍 규칙이 있단다.

http://www.boost.org/doc/libs/1_53_0/more/getting_started/windows.html#library-naming

하.. 영어.. 요것도 퍼옴 ㅠㅠ

원문 출처 : http://anster.egloos.com/2157882



자.. 이제 준비 다 됨.

boost library 사용하려면 include, src 경로를 프로젝트에 포함시키고

빌드된 라이브러리가 필요할 경우엔 stage 경로를 설정해주면 된다.



서명 도구 : signtool.exe

저장소/잡다한거

MSDN : http://msdn.microsoft.com/ko-kr/library/8s9b9yaz(v=vs.100).aspx

googletest : Google C++ Testing Framework

저장소/google test

googletest : Google C++ Testing Framework


Project Main    : https://code.google.com/p/googletest/

Downloads      : https://code.google.com/p/googletest/downloads/list

Wiki                : https://code.google.com/p/googletest/w/list